Posted January 1, 201510 yr Hello everybody While trying to make a cable block, I wanted to make the itemblock for the cable, so it could render in the inventory (because the bock has a special rendering). But whatever I do, the texture doesn't seem to wanna work. I checked if the texture was recognized, it was, but why isn't it being used? ItemBlockCable package com.invizzble.SC.item; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import com.invizzble.SC.lib.Info; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ItemBlockCable extends ItemBlock{ long hexaString; public ItemBlockCable(Block block, Long red, Long green, Long blue) { super(block); hexaString = Long.valueOf(Long.toHexString(red)+Long.toHexString(green)+Long.toHexString(blue), 16); } // @SideOnly(Side.CLIENT) // @Override // public int getColorFromItemStack(ItemStack stack, int par1) { // return (int)hexaString; // } // @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { itemIcon = iconRegister.registerIcon(Info.MOD_ID+":cable"); } } Cable block package com.invizzble.SC.block; import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import com.invizzble.SC.lib.BlockInfo; import com.invizzble.SC.lib.Info; import com.invizzble.SC.tileEntities.BaseTileEntityCable; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public abstract class SCBlockCable extends SCBlockMachine { public SCBlockCable() { setBlockBounds(BlockInfo.CABLE_MIN_CONSTANT, BlockInfo.CABLE_MIN_CONSTANT, BlockInfo.CABLE_MIN_CONSTANT, BlockInfo.CABLE_MAX_CONSTANT, BlockInfo.CABLE_MAX_CONSTANT, BlockInfo.CABLE_MAX_CONSTANT); } @Override public boolean isOpaqueCube() { return false; } @Override public int getRenderType() { return -1; } @Override public boolean renderAsNormalBlock() { return false; } @Override public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { BaseTileEntityCable cable = (BaseTileEntityCable) world.getTileEntity( x, y, z); if (cable != null) { float minX = BlockInfo.CABLE_MIN_CONSTANT - (cable.isCableConnected(ForgeDirection.WEST) ? (6 / 16F): 0); float maxX = BlockInfo.CABLE_MAX_CONSTANT + (cable.isCableConnected(ForgeDirection.EAST) ? (6 / 16F): 0); float minY = BlockInfo.CABLE_MIN_CONSTANT - (cable.isCableConnected(ForgeDirection.DOWN) ? (6 / 16F): 0); float maxY = BlockInfo.CABLE_MAX_CONSTANT + (cable.isCableConnected(ForgeDirection.UP) ? (6 / 16F): 0); float minZ = BlockInfo.CABLE_MIN_CONSTANT - (cable.isCableConnected(ForgeDirection.NORTH) ? (6 / 16F): 0); float maxZ = BlockInfo.CABLE_MAX_CONSTANT + (cable.isCableConnected(ForgeDirection.SOUTH) ? (6 / 16F): 0); setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ); } return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); } // @Override // public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, // int y, int z) { // // return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z // + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); // } @Override public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, List list, Entity entity) { BaseTileEntityCable cable = (BaseTileEntityCable) world.getTileEntity(x, y, z); if (cable != null) { float minX = BlockInfo.CABLE_MIN_CONSTANT - (cable.isCableConnected(ForgeDirection.WEST) ? (6 / 16F): 0); float maxX = BlockInfo.CABLE_MAX_CONSTANT + (cable.isCableConnected(ForgeDirection.EAST) ? (6 / 16F): 0); float minY = BlockInfo.CABLE_MIN_CONSTANT - (cable.isCableConnected(ForgeDirection.DOWN) ? (6 / 16F): 0); float maxY = BlockInfo.CABLE_MAX_CONSTANT + (cable.isCableConnected(ForgeDirection.UP) ? (6 / 16F): 0); float minZ = BlockInfo.CABLE_MIN_CONSTANT - (cable.isCableConnected(ForgeDirection.NORTH) ? (6 / 16F): 0); float maxZ = BlockInfo.CABLE_MAX_CONSTANT + (cable.isCableConnected(ForgeDirection.SOUTH) ? (6 / 16F): 0); setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ); } super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); } } registering GameRegistry.registerBlock(copperCable, ItemBlockCable.class, "copperCable", (long)255, (long)255, (long)255); Anyway, thanks for reading. http://i.imgur.com/sKDS7bj.png[/img] http://www.minecraftforum.net/topic/1877292-15x-forge-smp-nightmarecraft-alpha-10-it-started-with-a-dream-new/
January 2, 201510 yr Author Thanks man, that worked! I feel such a noob right now. http://i.imgur.com/sKDS7bj.png[/img] http://www.minecraftforum.net/topic/1877292-15x-forge-smp-nightmarecraft-alpha-10-it-started-with-a-dream-new/
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.