Jump to content

Forge 1.7.10 Textures Not Working


thewibi77

Recommended Posts

i am making a mod with a custom furnace but the texture doesn't work and i can't find what's wrong

here is my code

import java.util.Random;

import com.coruptableMod2.corruptable2mod.CoruptableModV2;
import com.coruptableMod2.corruptable2mod.tileEntity.TileEntityCompressor;

import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
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.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class BlockCompressor extends BlockContainer {

private final Random maceratorRand = new Random();

private final boolean isActive;

private static boolean keepCompressorInventory;
@SideOnly(Side.CLIENT)
private IIcon compressorIconTop;

public BlockCompressor(boolean isActive) {
	super(Material.rock);

	this.isActive = isActive;
}

@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister){
	this.blockIcon = iconRegister.registerIcon(CoruptableModV2.MODID + ":" + "macerator_side");
	this.compressorIconTop = iconRegister.registerIcon(CoruptableModV2.MODID +":"+(this.isActive ? "macerator_front_lit" : "Compressor"));
}

@SideOnly(Side.CLIENT)

/**
 * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
 */
public IIcon getIcon(int par1, int par2)
{
	return par1 == 1 ? this.blockIcon : (par1 == 0 ? this.blockIcon : (par1 != par2 ? this.blockIcon : this.compressorIconTop));
}

/**
 * Returns the ID of the items to drop on destruction.
 */
public Block idDropped(int par1, Random par2Random, int par3)
{
	return CoruptableModV2.blockCompressorIdle;
}   

/**
 * Called whenever the block is added into the world. Args: world, x, y, z
 */
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
	super.onBlockAdded(par1World, par2, par3, par4);
	this.setDefaultDirection(par1World, par2, par3, par4);
}

/**
 * set a blocks direction
 */
private void setDefaultDirection(World par1World, int par2, int par3, int par4)
{
	if (!par1World.isRemote)
	{

		byte b0 = 3;

		par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2);
	}
}

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
	if(!world.isRemote) {
		FMLNetworkHandler.openGui(player, CoruptableModV2.instance, CoruptableModV2.guiIdCompressor, world, x, y, z);
	}

	return true;
}

/**
 * Update which block ID the furnace is using depending on whether or not it is burning
 */
public static void updateFurnaceBlockState(boolean par0, World par1World, int par2, int par3, int par4)
{
	int l = par1World.getBlockMetadata(par2, par3, par4);
	TileEntity tileentity = par1World.getTileEntity(par2, par3, par4);
	keepCompressorInventory = true;

	if (par0)
	{
		par1World.setBlock(par2, par3, par4, CoruptableModV2.blockCompressorActive);
	}
	else
	{
		par1World.setBlock(par2, par3, par4, CoruptableModV2.blockCompressorIdle);
	}

	keepCompressorInventory = false;
	par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2);

	if (tileentity != null)
	{
		tileentity.validate();
		par1World.setTileEntity(par2, par3, par4, tileentity);
	}
}

/**
 * Returns a new instance of a block's tile entity class. Called on placing the block.
 */
public TileEntity createNewTileEntity(World par1World)
{
	return new TileEntityCompressor();
}

/**
 * Called when the block is placed in the world.
 */
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
{
	int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

	if (l == 0)
	{
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2);
	}

	if (l == 1)
	{
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2);
	}

	if (l == 2)
	{
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2);
	}

	if (l == 3)
	{
		par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2);
	}

	if (par6ItemStack.hasDisplayName())
	{
		((TileEntityCompressor)par1World.getTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName());
	}
}

/**
 * ejects contained items into the world, and notifies neighbours of an update, as appropriate
 */
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6)
{
	if (!keepCompressorInventory)
	{
		TileEntityCompressor TileEntityCompressor = (TileEntityCompressor)par1World.getTileEntity(par2, par3, par4);

		if (TileEntityCompressor != null)
		{
			for (int j1 = 0; j1 < TileEntityCompressor.getSizeInventory(); ++j1)
			{
				ItemStack itemstack = TileEntityCompressor.getStackInSlot(j1);

				if (itemstack != null)
				{
					float f = this.maceratorRand.nextFloat() * 0.8F + 0.1F;
					float f1 = this.maceratorRand.nextFloat() * 0.8F + 0.1F;
					float f2 = this.maceratorRand.nextFloat() * 0.8F + 0.1F;

					while (itemstack.stackSize > 0)
					{
						int k1 = this.maceratorRand.nextInt(21) + 10;

						if (k1 > itemstack.stackSize)
						{
							k1 = itemstack.stackSize;
						}

						itemstack.stackSize -= k1;
						EntityItem entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));

						if (itemstack.hasTagCompound())
						{
							entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
						}

						float f3 = 0.05F;
						entityitem.motionX = (double)((float)this.maceratorRand.nextGaussian() * f3);
						entityitem.motionY = (double)((float)this.maceratorRand.nextGaussian() * f3 + 0.2F);
						entityitem.motionZ = (double)((float)this.maceratorRand.nextGaussian() * f3);
						par1World.spawnEntityInWorld(entityitem);
					}
				}
			}

			par1World.func_147453_f(par2, par3, par4, CoruptableModV2.blockCompressorIdle);

		}
	}

	super.breakBlock(par1World, par2, par3, par4, par5, par6);
}

/**
 * If this returns true, then comparators facing away from this block will use the value from
 * getComparatorInputOverride instead of the actual redstone signal strength.
 */
public boolean hasComparatorInputOverride()
{
	return true;
}

/**
 * If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal
 * strength when this block inputs to a comparator.
 */
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)
{
	return Container.calcRedstoneFromInventory((IInventory)par1World.getTileEntity(par2, par3, par4));
}

@SideOnly(Side.CLIENT)

/**
 * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
 */
public Block idPicked(World par1World, int par2, int par3, int par4)
{
	return CoruptableModV2.blockCompressorIdle;
}

@Override
public TileEntity createNewTileEntity(World var1, int var2) {
	return new TileEntityCompressor();
}

}

Link to comment
Share on other sites

For one, why are you still on 1.7.10? Forge already has beta builds for 1.9...

 

Second, I don't think you know what you're doing. You called your block

BlockCompressor

, but you have several variables or methods with "macerator" in it. Like

maceratorRand

. This leads me to thinking you are randomly copy-pasting a tutorial or the vanilla furnace code.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

actually i changed my mind on this machine and i didn't rename everything to Compressor but everything works the GUI the recipes the GUI textures but not the texture of the block itself

 

but that is not what I'm asking

and why 1.7.10? because i want it to work in a big modpack and there is no such modpack in 1.8 and 1.9

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.