Jump to content

[Solved] Itemblock texture not working


invizzble

Recommended Posts

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.