mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-27 23:46:01 +00:00
Changed API signature to include Block & TileEntity for optimization
This commit is contained in:
1 parent
e953471d3e
commit
953e255189
3 files changed
+21
-19
No files matched your search
@@ -24,15 +24,13 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(World world, EntityPlayer player, MovingObjectPosition mop, IWailaConfigHandler config) {
|
||||
public ItemStack getWailaStack(World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config) {
|
||||
int blockID = world.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
|
||||
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
public List<String> getWailaHead(ItemStack itemStack, World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config) {
|
||||
int blockID = block.blockID;
|
||||
/* Mob spawner handler */
|
||||
if (blockID == mobSpawnerID && entity instanceof TileEntityMobSpawner && config.getConfig("vanilla.showspawntype")){
|
||||
String name = currenttip.get(0);
|
||||
@@ -44,9 +42,8 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config) {
|
||||
int blockID = world.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
public List<String> getWailaBody(ItemStack itemStack, World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config) {
|
||||
int blockID = block.blockID;
|
||||
/* Crops */
|
||||
if (config.getConfig("vanilla.showgrowthvalue"))
|
||||
if (blockID == cropsID || blockID == melonStemID || blockID == pumpkinStemID || blockID == carrotID || blockID == potatoID){
|
||||
|
||||
@@ -2,8 +2,10 @@ package mcp.mobius.waila.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -13,7 +15,7 @@ public interface IWailaBlock {
|
||||
* Return null if you want to use the default lookup system.
|
||||
* You get the world, the player and the location of the block. With that, it is easy to gather information & tile entities
|
||||
*/
|
||||
ItemStack getWailaStack(World world, EntityPlayer player, MovingObjectPosition mop, IWailaConfigHandler config);
|
||||
ItemStack getWailaStack(World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, IWailaConfigHandler config);
|
||||
|
||||
/* Waila HUD is divided into 3 zones. The head corresponds to the item name,
|
||||
* body to where you mostly want to put informations, and I reserve the tail for modname display
|
||||
@@ -30,6 +32,6 @@ public interface IWailaBlock {
|
||||
* Always return the currenttip is you don't want to modify the current zone.
|
||||
*/
|
||||
|
||||
List<String> getWailaHead(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config);
|
||||
List<String> getWailaBody(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config);
|
||||
List<String> getWailaHead(ItemStack itemStack, World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config);
|
||||
List<String> getWailaBody(ItemStack itemStack, World world, EntityPlayer player, TileEntity entity, Block block, MovingObjectPosition mop, List<String> currenttip, IWailaConfigHandler config);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.nei.api.IHighlightHandler;
|
||||
@@ -17,15 +18,16 @@ import codechicken.nei.api.ItemInfo.Layout;
|
||||
public class HUDHandlerExternal implements IHighlightHandler {
|
||||
@Override
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
|
||||
int blockID = world.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
|
||||
Block block = Block.blocksList[blockID];
|
||||
int blockID = world.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
|
||||
Block block = Block.blocksList[blockID];
|
||||
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
if (IWailaBlock.class.isInstance(block))
|
||||
return ((IWailaBlock)block).getWailaStack(world, player, mop, ConfigHandler.instance());
|
||||
return ((IWailaBlock)block).getWailaStack(world, player, entity, block, mop, ConfigHandler.instance());
|
||||
|
||||
if(ExternalModulesHandler.instance().hasStackProviders(blockID))
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getStackProviders(blockID)){
|
||||
ItemStack retval = dataProvider.getWailaStack(world, player, mop, ConfigHandler.instance());
|
||||
ItemStack retval = dataProvider.getWailaStack(world, player, entity, block, mop, ConfigHandler.instance());
|
||||
if (retval != null)
|
||||
return retval;
|
||||
}
|
||||
@@ -37,20 +39,21 @@ public class HUDHandlerExternal implements IHighlightHandler {
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
|
||||
int blockID = world.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
|
||||
Block block = Block.blocksList[blockID];
|
||||
TileEntity entity = world.getBlockTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
if (IWailaBlock.class.isInstance(block))
|
||||
if (layout == Layout.HEADER)
|
||||
return ((IWailaBlock)block).getWailaHead(itemStack, world, player, mop, currenttip, ConfigHandler.instance());
|
||||
return ((IWailaBlock)block).getWailaHead(itemStack, world, player, entity, block, mop, currenttip, ConfigHandler.instance());
|
||||
else if (layout == Layout.BODY)
|
||||
return ((IWailaBlock)block).getWailaBody(itemStack, world, player, mop, currenttip, ConfigHandler.instance());
|
||||
return ((IWailaBlock)block).getWailaBody(itemStack, world, player, entity, block, mop, currenttip, ConfigHandler.instance());
|
||||
|
||||
if (layout == Layout.HEADER && ExternalModulesHandler.instance().hasHeadProviders(blockID))
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getHeadProviders(blockID))
|
||||
currenttip = dataProvider.getWailaHead(itemStack, world, player, mop, currenttip, ConfigHandler.instance());
|
||||
currenttip = dataProvider.getWailaHead(itemStack, world, player, entity, block, mop, currenttip, ConfigHandler.instance());
|
||||
|
||||
if (layout == Layout.BODY && ExternalModulesHandler.instance().hasBodyProviders(blockID))
|
||||
for (IWailaDataProvider dataProvider : ExternalModulesHandler.instance().getBodyProviders(blockID))
|
||||
currenttip = dataProvider.getWailaBody(itemStack, world, player, mop, currenttip, ConfigHandler.instance());
|
||||
currenttip = dataProvider.getWailaBody(itemStack, world, player, entity, block, mop, currenttip, ConfigHandler.instance());
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user