Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.