Posted February 20, 20169 yr In one of my mods, I have a block that has a custom itemblock and it works correctly with the creative tab and with NEI. Block: package XFactHD.rfutilities.common.blocks.block; import XFactHD.rfutilities.common.blocks.itemBlock.ItemBlockRFCapacitor; import XFactHD.rfutilities.common.blocks.tileEntity.TileEntityCapacitor; import XFactHD.rfutilities.common.utils.LogHelper; import cofh.thermalexpansion.item.tool.ItemMultimeter; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class BlockRFCapacitor extends BlockBaseRFU { public BlockRFCapacitor() { super("blockCapacitor", Material.iron, 1, ItemBlockRFCapacitor.class); } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { int l = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0) { world.setBlockMetadataWithNotify(x, y, z, 5, 2); } if (l == 1) { world.setBlockMetadataWithNotify(x, y, z, 2, 2); } if (l == 2) { world.setBlockMetadataWithNotify(x, y, z, 3, 2); } if (l == 3) { world.setBlockMetadataWithNotify(x, y, z, 4, 2); } TileEntity te = world.getTileEntity(x, y, z); if (entity instanceof EntityPlayer && te instanceof TileEntityCapacitor) { if ((stack.stackTagCompound) != null) { int type = stack.stackTagCompound.getInteger("type"); ((TileEntityCapacitor)te).type = type; world.markBlockForUpdate(x, y, z); //LogHelper.info("Type on stack: " + type + "; Type on tile: " + ((TileEntityCapacitor)world.getTileEntity(x, y, z)).type); te.markDirty(); } } } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float hitX, float hitY, float hitZ) { TileEntity te = world.getTileEntity(x, y, z); if (te instanceof TileEntityCapacitor && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemMultimeter && !world.isRemote) { player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("desc.rfutilities:stored.name") + " " + ((TileEntityCapacitor)te).getEnergyStored(ForgeDirection.UNKNOWN) + " " + StatCollector.translateToLocal("desc.rfutilities:rf.name") + " / " + ((TileEntityCapacitor)te).getMaxEnergyStored(ForgeDirection.UNKNOWN) + " " + StatCollector.translateToLocal("desc.rfutilities:rf.name"))); //LogHelper.info(((TileEntityCapacitor)world.getTileEntity(x, y, z)).type); return true; } return false; } @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { ItemStack stack = new ItemStack(this, 1); NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("type", ((TileEntityCapacitor)world.getTileEntity(x, y, z)).type); stack.setTagCompound(compound); return stack; } @Override public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityCapacitor(); } @Override public int getRenderType() { return -1; } @Override public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } } ItemBlock: package XFactHD.rfutilities.common.blocks.itemBlock; import XFactHD.rfutilities.common.blocks.block.BlockRFCapacitor; import XFactHD.rfutilities.common.blocks.tileEntity.TileEntityCapacitor; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import java.util.List; public class ItemBlockRFCapacitor extends ItemBlock { public ItemBlockRFCapacitor(Block b) { super(b); } @Override public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { if (entity instanceof EntityPlayer && block instanceof BlockRFCapacitor) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("type", ((TileEntityCapacitor)world.getTileEntity(x, y, z)).type); stack.setTagCompound(compound); } return true; } @Override public void getSubItems(Item item, CreativeTabs tabs, List list) { ItemStack capTEBasic = new ItemStack(item, 1); ItemStack capTEHardened = new ItemStack(item, 1); ItemStack capTEReinforced = new ItemStack(item, 1); ItemStack capTEResonant = new ItemStack(item, 1); ItemStack capEIOBasic = new ItemStack(item, 1); ItemStack capEIODouble = new ItemStack(item, 1); ItemStack capEIOVibrant = new ItemStack(item, 1); NBTTagCompound compoundCapTEBasic = new NBTTagCompound(); NBTTagCompound compoundCapTEHardened = new NBTTagCompound(); NBTTagCompound compoundCapTEReinforced = new NBTTagCompound(); NBTTagCompound compoundCapTEResonant = new NBTTagCompound(); NBTTagCompound compoundCapEIOBasic = new NBTTagCompound(); NBTTagCompound compoundCapEIODouble = new NBTTagCompound(); NBTTagCompound compoundCapEIOVibrant = new NBTTagCompound(); compoundCapTEBasic.setInteger("type", 1); compoundCapTEHardened.setInteger("type", 2); compoundCapTEReinforced.setInteger("type", 3); compoundCapTEResonant.setInteger("type", 4); compoundCapEIOBasic.setInteger("type", 5); compoundCapEIODouble.setInteger("type", 6); compoundCapEIOVibrant.setInteger("type", 7); capTEBasic.setTagCompound(compoundCapTEBasic); capTEHardened.setTagCompound(compoundCapTEHardened); capTEReinforced.setTagCompound(compoundCapTEReinforced); capTEResonant.setTagCompound(compoundCapTEResonant); capEIOBasic.setTagCompound(compoundCapEIOBasic); capEIODouble.setTagCompound(compoundCapEIODouble); capEIOVibrant.setTagCompound(compoundCapEIOVibrant); list.add(capTEBasic); list.add(capTEHardened); list.add(capTEReinforced); list.add(capTEResonant); list.add(capEIOBasic); list.add(capEIODouble); list.add(capEIOVibrant); super.getSubItems(item, tabs, list); } @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { if (stack.hasTagCompound() && stack.stackTagCompound.hasKey("type")) { int type = stack.stackTagCompound.getInteger("type"); String info = StatCollector.translateToLocal("desc.rfutilities:capType.name"); String typeName = StatCollector.translateToLocal("desc.rfutilities:capType_" + type + ".name"); list.add(info + " " + typeName); } super.addInformation(stack, player, list, bool); } } In my current main mod I also have a block with a custom itemblock and it shows up twice in the creative tab and in NEI. Block: package XFactHD.thermalreactors.common.blocks.machine.miscellaneous; import XFactHD.thermalreactors.ThermalReactors; import XFactHD.thermalreactors.common.blocks.BlockBaseTR; import XFactHD.thermalreactors.common.util.Reference; import cofh.thermalexpansion.item.tool.ItemMultimeter; import cofh.thermalexpansion.item.tool.ItemWrench; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; public class BlockRFHandler extends BlockBaseTR { public BlockRFHandler() { super("blockRFHandler", Material.iron, 1, ItemBlockRFHandler.class, "NuclearDynamo", "PlutoniumEnergyCell", "PlasmaEnergyCell"); setCreativeTab(ThermalReactors.creativeTab); } @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { ItemStack stack; TileEntity te = world.getTileEntity(x, y, z); NBTTagCompound compound = new NBTTagCompound(); switch (world.getBlockMetadata(x, y, z)) { case 0: return new ItemStack(this, 1, 0); case 1: stack = new ItemStack(this, 1, 1); compound.setInteger("storage", ((TileEntityPlutoniumEnergyCell)te).energyStorage.getEnergyStored()); compound.setInteger("maxStorage", ((TileEntityPlutoniumEnergyCell)te).energyStorage.getMaxEnergyStored()); compound.setIntArray("sides", ((TileEntityPlutoniumEnergyCell)te).sides); compound.setInteger("redstoneMode", ((TileEntityPlutoniumEnergyCell)te).mode); compound.setInteger("maxInput", ((TileEntityPlutoniumEnergyCell)te).input); compound.setInteger("maxOutput", ((TileEntityPlutoniumEnergyCell)te).output); stack.setTagCompound(compound); return stack; case 2: stack = new ItemStack(this, 1, 1); compound.setInteger("storage", ((TileEntityPlasmaEnergyCell)te).energyStorage.getEnergyStored()); compound.setInteger("maxStorage", ((TileEntityPlasmaEnergyCell)te).energyStorage.getMaxEnergyStored()); compound.setIntArray("sides", ((TileEntityPlasmaEnergyCell)te).sides); compound.setInteger("redstoneMode", ((TileEntityPlasmaEnergyCell)te).mode); compound.setInteger("maxInput", ((TileEntityPlasmaEnergyCell)te).input); compound.setInteger("maxOutput", ((TileEntityPlasmaEnergyCell)te).output); stack.setTagCompound(compound); return stack; } return super.getPickBlock(target, world, x, y, z, player); } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase livingBase, ItemStack stack) { int l = MathHelper.floor_double((double) (livingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; TileEntity te = world.getTileEntity(x, y, z); if (stack.getItemDamage() == 0) { ((TileEntityNuclearDynamo)world.getTileEntity(x, y, z)).setFacingToHandlers(); return; } if (stack.getItemDamage() == 1) { if (l == 0) { ((TileEntityPlutoniumEnergyCell)te).facing = 1; } else if (l == 1) { ((TileEntityPlutoniumEnergyCell)te).facing = 2; } else if (l == 2) { ((TileEntityPlutoniumEnergyCell)te).facing = 3; } else if (l == 3) { ((TileEntityPlutoniumEnergyCell)te).facing = 4; } if (stack.hasTagCompound()) { ((TileEntityPlutoniumEnergyCell)te).energyStorage.setEnergyStored(stack.getTagCompound().getInteger("storage")); ((TileEntityPlutoniumEnergyCell)te).sides = stack.getTagCompound().getIntArray("sides"); ((TileEntityPlutoniumEnergyCell)te).mode = stack.getTagCompound().getInteger("redstoneMode"); ((TileEntityPlutoniumEnergyCell)te).input = stack.getTagCompound().getInteger("maxInput"); ((TileEntityPlutoniumEnergyCell)te).output = stack.getTagCompound().getInteger("maxOutput"); world.markBlockForUpdate(x, y, z); } return; } if (stack.getItemDamage() == 2) { if (l == 0) { ((TileEntityPlasmaEnergyCell)te).facing = 1; } else if (l == 1) { ((TileEntityPlasmaEnergyCell)te).facing = 2; } else if (l == 2) { ((TileEntityPlasmaEnergyCell)te).facing = 3; } else if (l == 3) { ((TileEntityPlasmaEnergyCell)te).facing = 4; } if (stack.hasTagCompound()) { ((TileEntityPlasmaEnergyCell)te).energyStorage.setEnergyStored(stack.getTagCompound().getInteger("storage")); ((TileEntityPlasmaEnergyCell)te).sides = stack.getTagCompound().getIntArray("sides"); ((TileEntityPlasmaEnergyCell)te).mode = stack.getTagCompound().getInteger("redstoneMode"); ((TileEntityPlasmaEnergyCell)te).input = stack.getTagCompound().getInteger("maxInput"); ((TileEntityPlasmaEnergyCell)te).output = stack.getTagCompound().getInteger("maxOutput"); world.markBlockForUpdate(x, y, z); } } } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { int meta = world.getBlockMetadata(x, y, z); TileEntity te = world.getTileEntity(x, y, z); ItemStack item = player.getCurrentEquippedItem(); if (!player.isSneaking()) { if (te instanceof TileEntityPlutoniumEnergyCell && item != null && item.getItem() instanceof ItemMultimeter && !world.isRemote) { player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("desc.thermalreactors:storage.name") + " " + ((TileEntityPlutoniumEnergyCell)te).energyStorage.getEnergyStored() + "/" + ((TileEntityPlutoniumEnergyCell)te).energyStorage.getMaxEnergyStored() + " RF")); } if (te instanceof TileEntityPlasmaEnergyCell && item != null && item.getItem() instanceof ItemMultimeter && !world.isRemote) { player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("desc.thermalreactors:storage.name") + " " + ((TileEntityPlasmaEnergyCell)te).energyStorage.getEnergyStored() + "/" + ((TileEntityPlasmaEnergyCell)te).energyStorage.getMaxEnergyStored() + " RF")); } if (item != null && item.getItem() instanceof ItemWrench) { if (meta == 0 && te instanceof TileEntityNuclearDynamo) { if (((TileEntityNuclearDynamo)te).facing < 5) { ((TileEntityNuclearDynamo)te).facing = ((TileEntityNuclearDynamo)te).facing+1; } else if (((TileEntityNuclearDynamo)te).facing == 5) { ((TileEntityNuclearDynamo)te).facing = 0; } } if (meta == 1 && te instanceof TileEntityPlutoniumEnergyCell) { if (((TileEntityPlutoniumEnergyCell)te).facing < 4) { ((TileEntityPlutoniumEnergyCell)te).facing = ((TileEntityPlutoniumEnergyCell)te).facing+1; world.markBlockForUpdate(x, y, z); } else if (((TileEntityPlutoniumEnergyCell)te).facing == 4) { ((TileEntityPlutoniumEnergyCell)te).facing = 1; world.markBlockForUpdate(x, y, z); } } } if (item == null || !(item.getItem() instanceof ItemMultimeter || item.getItem() instanceof ItemWrench) && !world.isRemote) { switch (meta) { case 0: player.openGui(ThermalReactors.instance, Reference.GUI_ID_NUCLEARDYNAMO, world, x, y, z); return true; case 1: player.openGui(ThermalReactors.instance, Reference.GUI_ID_RFSTORAGE_PLUTONIUM, world, x, y, z); return true; case 2: //player.openGui(ThermalReactors.instance, Reference.GUI_ID_RFSTORAGE_PLASMA, world, x, y, z); return true; default: return false; } } } return false; } @Override public void registerBlockIcons(IIconRegister iconRegister) { icons[0][0] = iconRegister.registerIcon(Reference.MOD_ID + ":" + "blockRFHandler" + "_" + "Dynamo"); icons[1][0] = iconRegister.registerIcon(Reference.MOD_ID + ":" + "blockRFHandler" + "_" + "Cell_Plutonium"); icons[2][0] = iconRegister.registerIcon(Reference.MOD_ID + ":" + "blockRFHandler" + "_" + "Cell_Plasma"); } @Override public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { int meta = world.getBlockMetadata(x, y, z); switch (meta) { case 0: return icons[0][0]; case 1: return icons[1][0]; case 2: return icons[2][0]; } return super.getIcon(world, x, y, z, side); } @Override public TileEntity createNewTileEntity(World world, int meta) { switch (meta) { case 0: return new TileEntityNuclearDynamo(); case 1: return new TileEntityPlutoniumEnergyCell(); case 2: return new TileEntityPlasmaEnergyCell(); default: return null; } } @Override public int getRenderType() { return -1; } @Override public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } @Override public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { if (world.getBlockMetadata(x, y, z) == 0) { } else if (world.getBlockMetadata(x, y, z) == 1) { return true; } return false; } @Override public boolean canDismantle(EntityPlayer entityPlayer, World world, int x, int y, int z) { return true; } @Override public ArrayList<ItemStack> dismantleBlock(EntityPlayer entityPlayer, World world, int x, int y, int z, boolean b) { ArrayList stacks = new ArrayList<ItemStack>(1); TileEntity te = world.getTileEntity(x, y, z); NBTTagCompound compound = new NBTTagCompound(); if (world.getBlockMetadata(x, y, z) == 0) { stacks.add(new ItemStack(this, 1, 0)); } else if (world.getBlockMetadata(x, y, z) == 1) { ItemStack stack = new ItemStack(this, 1, 1); compound.setInteger("storage", ((TileEntityPlutoniumEnergyCell) te).energyStorage.getEnergyStored()); compound.setIntArray("sides", ((TileEntityPlutoniumEnergyCell) te).sides); stack.setTagCompound(compound); stacks.add(stack); } return stacks; } } ItemBlock: package XFactHD.thermalreactors.common.blocks.machine.miscellaneous; import XFactHD.thermalreactors.ThermalReactors; import XFactHD.thermalreactors.common.blocks.ItemBlockBaseTR; import XFactHD.thermalreactors.common.util.Utils; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import java.util.List; public class ItemBlockRFHandler extends ItemBlockBaseTR { public ItemBlockRFHandler(Block b) { super(b); this.setCreativeTab(ThermalReactors.creativeTab); this.setMaxStackSize(1); } @Override public int getMaxDamage(ItemStack stack) { return stack.hasTagCompound() ? (stack.getItemDamage() == 1 ? 320000000 : (stack.getItemDamage() == 2 ? 1280000000 : 0)) : 0; } @Override public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { if (entity instanceof EntityPlayer && block instanceof BlockRFHandler) { TileEntity te = world.getTileEntity(x, y, z); NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("storage", ((TileEntityPlasmaEnergyCell)te).energyStorage.getEnergyStored()); compound.setInteger("maxStorage", ((TileEntityPlasmaEnergyCell)te).energyStorage.getMaxEnergyStored()); compound.setIntArray("sides", ((TileEntityPlasmaEnergyCell)te).sides); compound.setInteger("redstoneMode", ((TileEntityPlasmaEnergyCell)te).mode); compound.setInteger("maxInput", ((TileEntityPlasmaEnergyCell)te).input); compound.setInteger("maxOutput", ((TileEntityPlasmaEnergyCell)te).output); stack.setTagCompound(compound); } return true; } @Override public boolean isDamageable() { return true; } @Override public void getSubItems(Item item, CreativeTabs tab, List list) { ItemStack dynamo = new ItemStack(item, 1, 0); ItemStack emptyPlutonium = new ItemStack(item, 1, 1); ItemStack fullPlutonium = new ItemStack(item, 1, 1); ItemStack emptyPlasma = new ItemStack(item, 1, 2); ItemStack fullPlasma = new ItemStack(item, 1, 2); int[] sides = new int[]{1, 2, 1, 1, 1, 1}; NBTTagCompound compoundPlutoniumEmpty = new NBTTagCompound(); compoundPlutoniumEmpty.setInteger("storage", 0); compoundPlutoniumEmpty.setInteger("maxStorage", 320000000); compoundPlutoniumEmpty.setIntArray("sides", sides); compoundPlutoniumEmpty.setInteger("maxInput", 128000); compoundPlutoniumEmpty.setInteger("maxOutput", 128000); compoundPlutoniumEmpty.setInteger("redstoneMode", 1); NBTTagCompound compoundPlutoniumFull = new NBTTagCompound(); compoundPlutoniumFull.setInteger("storage", 320000000); compoundPlutoniumFull.setInteger("maxStorage", 320000000); compoundPlutoniumFull.setIntArray("sides", sides); compoundPlutoniumFull.setInteger("maxInput", 128000); compoundPlutoniumFull.setInteger("maxOutput", 128000); compoundPlutoniumFull.setInteger("redstoneMode", 1); NBTTagCompound compoundPlasmaEmpty = new NBTTagCompound(); compoundPlasmaEmpty.setInteger("storage", 0); compoundPlasmaEmpty.setInteger("maxStorage", 1280000000); compoundPlasmaEmpty.setIntArray("sides", sides); compoundPlasmaEmpty.setInteger("maxInput", 512000); compoundPlasmaEmpty.setInteger("maxOutput", 512000); compoundPlasmaEmpty.setInteger("redstoneMode", 1); NBTTagCompound compoundPlasmaFull = new NBTTagCompound(); compoundPlasmaFull.setInteger("storage", 1280000000); compoundPlasmaFull.setInteger("maxStorage", 1280000000); compoundPlasmaFull.setIntArray("sides", sides); compoundPlasmaFull.setInteger("maxInput", 512000); compoundPlasmaFull.setInteger("maxOutput", 512000); compoundPlasmaFull.setInteger("redstoneMode", 1); emptyPlutonium.setTagCompound(compoundPlutoniumEmpty); fullPlutonium.setTagCompound(compoundPlutoniumFull); emptyPlasma.setTagCompound(compoundPlasmaEmpty); fullPlasma.setTagCompound(compoundPlasmaFull); list.add(dynamo); list.add(emptyPlutonium); list.add(fullPlutonium); list.add(emptyPlasma); list.add(fullPlasma); super.getSubItems(item, tab, list); } @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { if (stack.getItemDamage() >= 1) { if (stack.hasTagCompound()) { //if (EventHandler.sneak) //{ int storage = stack.getTagCompound().getInteger("storage"); int max = stack.getTagCompound().getInteger("maxStorage"); int in = stack.getTagCompound().getInteger("maxInput"); int out = stack.getTagCompound().getInteger("maxOutput"); int mode = stack.getTagCompound().getInteger("redstoneMode"); String text = StatCollector.translateToLocal("desc.thermalreactors:storage.name"); String text1 = StatCollector.translateToLocal("desc.thermalreactors:inout.name"); String text2 = StatCollector.translateToLocal("desc.thermalreactors:signal.name"); String text3 = StatCollector.translateToLocal("desc.thermalreactors:disabled.name"); String text4 = StatCollector.translateToLocal("desc.thermalreactors:enabled.name"); String text5 = StatCollector.translateToLocal("desc.thermalreactors:low.name"); String text6 = StatCollector.translateToLocal("desc.thermalreactors:high.name"); list.add(text + " " + Utils.getStringFromInt("", storage, "") + "/" + Utils.getStringFromInt("", max, "") + " RF"); list.add(text1 + " " + in + "/" + out + "RF/t"); list.add(text2 + " " + (mode==0 ? EnumChatFormatting.RED + text3 : EnumChatFormatting.GREEN + text4 + EnumChatFormatting.GRAY + ", " + (mode==2 ? text6 : text5))); /*} else { String text = StatCollector.translateToLocal("desc.thermalreactors:hold.name"); String text1 = StatCollector.translateToLocal("desc.thermalreactors:shift.name"); String text2 = StatCollector.translateToLocal("desc.thermalreactors:info.name"); list.add(text + " " + EnumChatFormatting.YELLOW + EnumChatFormatting.ITALIC + text1 + " " + EnumChatFormatting.GRAY + text2); }*/ } } super.addInformation(stack, player, list, bool); } @Override public double getDurabilityForDisplay(ItemStack stack) { if (stack.getItemDamage() >= 1) { if (stack.hasTagCompound()) { int storage = stack.getTagCompound().getInteger("storage"); int max = stack.getTagCompound().getInteger("maxStorage") > 0 ? stack.getTagCompound().getInteger("maxStorage") : 1; return (double)(1-(storage/max)); } } return super.getDurabilityForDisplay(stack); } }
February 20, 20169 yr Thanks, that fixed it. In the other mod I have the problem that some blocks are not added to the creative tab no matter if setCreativeTab is called on all of them including the base block or only on the base block. They are all shown in NEI nonetheless. Do you need any code to give me a tip?
February 20, 20169 yr Base Block: package XFactHD.rfutilities.common.blocks.block; import XFactHD.rfutilities.RFUtilities; import XFactHD.rfutilities.common.utils.Reference; import cofh.api.block.IDismantleable; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import java.util.ArrayList; import java.util.List; public abstract class BlockBaseRFU extends BlockContainer implements IDismantleable { public String name; public String[] subNames; public final IIcon[][] icons; protected final int iconDimensions; public BlockBaseRFU(String name, Material mat, int iconDimensions, Class<? extends ItemBlock> itemblock, String... subNames) { super(mat); this.subNames = subNames; this.name = name; this.icons = new IIcon[subNames.length][iconDimensions]; this.iconDimensions = iconDimensions; this.setBlockName(Reference.MOD_ID + ":" + name); GameRegistry.registerBlock(this, itemblock, name); this.setCreativeTab(RFUtilities.creativeTab); } @Override public int damageDropped(int meta) { return meta; } @Override public void getSubBlocks(Item item, CreativeTabs tab, List list) { for(int i=0; i<subNames.length; i++) { list.add(new ItemStack(item, 1, i)); } } @Override public void registerBlockIcons(IIconRegister iconRegister) { for(int i=0;i<subNames.length;i++) icons[i][0] = iconRegister.registerIcon(Reference.MOD_ID + ":" + name + "_" + subNames[i]); } @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { if(meta<icons.length) { return icons[meta][getSideForTexture(side)]; } return null; } protected int getSideForTexture(int side) { if(iconDimensions==2) { return side==0||side==1?0: 1; } if(iconDimensions==4) { return side<2?side: side==2||side==3?2: 3; } return Math.min(side, iconDimensions-1); } @Override public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { return false; } @Override public boolean canDismantle(EntityPlayer entityPlayer, World world, int i, int i1, int i2) { return false; } @Override public ArrayList<ItemStack> dismantleBlock(EntityPlayer entityPlayer, World world, int x, int y, int z, boolean b) { return null; } } One of the affected blocks: package XFactHD.rfutilities.common.blocks.block; import XFactHD.rfutilities.RFUtilities; import XFactHD.rfutilities.common.blocks.tileEntity.TileEntityResistor; import XFactHD.rfutilities.common.utils.Reference; import cofh.thermalexpansion.item.tool.ItemMultimeter; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import net.minecraft.world.World; public class BlockRFResistor extends BlockBaseRFU { public BlockRFResistor() { super("blockResistor", Material.iron, 1, ItemBlock.class); //setCreativeTab(RFUtilities.creativeTab); } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLivingBase, ItemStack stack) { int l = MathHelper.floor_double((double) (entityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0) { world.setBlockMetadataWithNotify(x, y, z, 5, 2); } if (l == 1) { world.setBlockMetadataWithNotify(x, y, z, 2, 2); } if (l == 2) { world.setBlockMetadataWithNotify(x, y, z, 3, 2); } if (l == 3) { world.setBlockMetadataWithNotify(x, y, z, 4, 2); } } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float hitX, float hitY, float hitZ) { TileEntity te = world.getTileEntity(x, y, z); if (te instanceof TileEntityResistor && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemMultimeter && !world.isRemote) { player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("desc.rfutilities:through.name") + " " + ((TileEntityResistor)te).throughput + " " + StatCollector.translateToLocal("desc.rfutilities:rftick.name"))); return true; } //player.openGui(RFUtilities.instance, Reference.GUI_ID_RES, world, x, y, z); return false; } @Override public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityResistor(); } @Override public int getRenderType() { return -1; } @Override public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.