Jump to content

Custom Furnace not turning when placed


hihellobyeoh

Recommended Posts

basically when i place my furnace (called blast furnace) it doesn't turn toward me like a normal furnace would. i think it's something i messed up in the tile entity but i can't figure out what. here is the tile entity file and the Block file:

 

BlastFurnace.java:

package com.advancedtunnelbore.block;

import java.util.Random;

import com.advancedtunnelbore.lib.RefStrings;
import com.advancedtunnelbore.main.MainRegistry;
import com.advancedtunnelbore.tile_entity.TileEntityBlastFurnace;

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.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
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.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class BlastFurnace extends BlockContainer {

@SideOnly(Side.CLIENT)
private IIcon top;
@SideOnly(Side.CLIENT)
private IIcon front;

private static boolean isBurning;
private final boolean isBurning2;
private final Random random = new Random();

protected BlastFurnace(boolean isActive) {
	super(Material.rock);
	isBurning2 = isActive;
}

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconregister){
	this.blockIcon = iconregister.registerIcon(this.isBurning ? RefStrings.MODID + ":BlastFurnaceSideActive" : RefStrings.MODID + ":BlastFurnaceSideInactive" );
	this.front = iconregister.registerIcon(this.isBurning ? RefStrings.MODID + ":BlastFurnaceActive" : RefStrings.MODID + ":BlastFurnaceInactive" );
	this.top = iconregister.registerIcon(RefStrings.MODID + ":BlastFurnaceTop");
}

public IIcon getIcon(int side, int meta){
	if(side == 1){
		return top;
	}else if(side == 5){
		return front;
	}else if(side == 0){
		return top;
	}else{
		return this.blockIcon;
	}
}

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
	player.openGui(MainRegistry.modInstance, 0, world, x, y, z);
	return true;
}

public Item getItemDropped(int par1, Random random, int par3){
	return Item.getItemFromBlock(MyBlocks.blastFurnace);
}

public Item getItem(World world, int par2, int par3, int par4){
	return Item.getItemFromBlock(MyBlocks.blastFurnace);
}

@SideOnly(Side.CLIENT)	
public void onBlockAdded(World world, int x, int y, int z){
	super.onBlockAdded(world, x, y, z);
	this.direction(world, x, y, z);
}

private void direction(World world, int x, int y, int z) {
	if(!world.isRemote){
		Block direction = world.getBlock(x,  y,  z - 1);
		Block direction1 = world.getBlock(x,  y,  z + 1);
		Block direction2 = world.getBlock(x - 1,  y,  z);
		Block direction3 = world.getBlock(x + 1,  y,  z);
		byte byte0 = 3;

		if(direction.func_149730_j() && direction.func_149730_j()){
			byte0 = 3;
		}
		if(direction1.func_149730_j() && direction1.func_149730_j()){
			byte0 = 2;
		}
		if(direction2.func_149730_j() && direction2.func_149730_j()){
			byte0 = 5;
		}
		if(direction3.func_149730_j() && direction3.func_149730_j()){
			byte0 = 4;
		}

		world.setBlockMetadataWithNotify(x, y, z, byte0, 2);
	}
}

public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack){
	int direction = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) +0.5D) & 3;

	if(direction == 0){
		world.setBlockMetadataWithNotify(x, y, z, 2, 2);
	}
	if(direction == 1){
		world.setBlockMetadataWithNotify(x, y, z, 5, 2);
	}
	if(direction == 2){
		world.setBlockMetadataWithNotify(x, y, z, 3, 2);
	}
	if(direction == 3){
		world.setBlockMetadataWithNotify(x, y, z, 4, 2);
	}
	if(itemstack.hasDisplayName()){
		((TileEntityBlastFurnace) world.getTileEntity(x, y, z)).furnaceName(itemstack.getDisplayName());
	}

}

public static void updateBlockState(boolean burning, World world, int x, int y, int z){
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileentity = world.getTileEntity(x, y, z);
	isBurning = true;

	if(burning){
		world.setBlock(x, y, z, MyBlocks.blastFurnaceActive);
	}else{
		world.setBlock(x, y, z, MyBlocks.blastFurnace);
	}

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if(tileentity != null){
		tileentity.validate();world.setTileEntity(x, y, z, tileentity);
	}
}

public void breakBlock(World world, int x, int y, int z, Block block, int meta){
	if(!isBurning){
		TileEntityBlastFurnace tileentityblastfurnace = (TileEntityBlastFurnace) world.getTileEntity(x, y, z);
		if(tileentityblastfurnace != null){
			for(int i = 0; i <tileentityblastfurnace.getSizeInventory(); ++i){
				ItemStack itemstack = tileentityblastfurnace.getStackInSlot(i);

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

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

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


						itemstack.stackSize -= j;
						EntityItem entityitem = new EntityItem(world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));

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

						float f3 = 0.025F;
						entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3);
						entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3 + 0.1F);
						entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3);
						world.spawnEntityInWorld(entityitem);
					}
				}
			}
			world.func_147453_f(x, y, z, block);
		}
	}
	super.breakBlock(world, x, y, z, block, meta);
}

@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random){
	if(this.isBurning2){
		int direction = world.getBlockMetadata(x, y, z);

		float xx = (float) x + 0.5F, yy = (float) y + random.nextFloat() * 6.0f / 16.0f, zz =(float) z+ 0.5F, xx2 = random.nextFloat() * 0.3F - 0.2F, zz2 = 0.5F;

		if (direction == 4) {
			world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
			world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
		} else if (direction == 5) {
			world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
			world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
		} else if (direction == 3) {
			world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
			world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
		} else if (direction == 2) {
			world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
			world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
		}
	}
}

@Override
public TileEntity createNewTileEntity(World world, int par2) {
	return new TileEntityBlastFurnace();
}	
}

 

TileEntityBlastFurnace.java:

package com.advancedtunnelbore.tile_entity;

import com.advancedtunnelbore.block.BlastFurnace;
import com.advancedtunnelbore.handler.BlastFurnaceRecipes;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;

public class TileEntityBlastFurnace extends TileEntity implements ISidedInventory {

private static final int[] slotsTop = new int[]{ 0 };
private static final int[] slotsBottom = new int[]{ 2, 1 };
private static final int[] slotsSides = new int[] { 1 };

private ItemStack[] furnaceItemStacks = new ItemStack[3];

public int furnaceBurnTime;
public int currentBurnTime;
public int furnaceCookTime;
private String furnaceName;

public void furnaceName(String string){
	this.furnaceName = string;
}


@Override
public int getSizeInventory() {
	return this.furnaceItemStacks.length;
}

@Override
public ItemStack getStackInSlot(int slot) {
	return this.furnaceItemStacks[slot];
}

@Override
public ItemStack decrStackSize(int var1, int var2) {
	if(this.furnaceItemStacks[var1] != null){
		ItemStack itemstack;
		if(this.furnaceItemStacks[var1].stackSize <= var2){
			itemstack = this.furnaceItemStacks[var1];
			this.furnaceItemStacks[var1] = null;
			return itemstack;
		}else{
			itemstack = this.furnaceItemStacks[var1].splitStack(var2);

			if(this.furnaceItemStacks[var1].stackSize == 0){
				this.furnaceItemStacks[var1] = null;
			}
			return itemstack;
		}
	}else{
		return null;
	}
}

@Override
public ItemStack getStackInSlotOnClosing(int slot) {
	if(this.furnaceItemStacks[slot] != null){
		ItemStack itemstack = this.furnaceItemStacks[slot];
		this.furnaceItemStacks[slot] = null;
		return itemstack;
	}else{
		return null;
	}
}

@Override
public void setInventorySlotContents(int slot, ItemStack itemstack) {
	this.furnaceItemStacks[slot] = itemstack;

	if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()){
		itemstack.stackSize = this.getInventoryStackLimit();
	}

}

@Override
public String getInventoryName() {
	return this.hasCustomInventoryName() ? this.furnaceName : "Blast Furnace";
}

@Override
public boolean hasCustomInventoryName() {
	return this.furnaceName != null && this.furnaceName.length() > 0;
}

@Override
public int getInventoryStackLimit() {
	return 64;
}

public void readFromNBT(NBTTagCompound tagCompound){
	super.readFromNBT(tagCompound);
	NBTTagList taglist = tagCompound.getTagList("Items", 10);
	this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];
	for(int i = 0; i < taglist.tagCount(); ++i){
		NBTTagCompound tagCompound1 = taglist.getCompoundTagAt(i);
		byte byte0 = tagCompound1.getByte("Slot");

		if(byte0 >= 0 && byte0 < this.furnaceItemStacks.length){
			this.furnaceItemStacks[byte0] = ItemStack.loadItemStackFromNBT(tagCompound1);
		}
	}

	this.furnaceBurnTime = tagCompound.getShort("BurnTime");
	this.furnaceCookTime = tagCompound.getShort("CookTime");
	this.currentBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);

	if(tagCompound.hasKey("CustomName", ){
		this.furnaceName = tagCompound.getString("CustomName");
	}
}

public void writeToNBT(NBTTagCompound tagCompound){
	super.writeToNBT(tagCompound);

	tagCompound.setShort("BurnTime", (short) this.furnaceBurnTime);
	tagCompound.setShort("CookTime", (short) this.furnaceBurnTime);
	NBTTagList tagList = new NBTTagList();

	for(int i = 0; i < this.furnaceItemStacks.length; ++i){
		if(this.furnaceItemStacks[i] != null){
			NBTTagCompound tagCompound1 = new NBTTagCompound();
			tagCompound1.setByte("slot", (byte) i);
			this.furnaceItemStacks[i].writeToNBT(tagCompound1);
			tagList.appendTag(tagCompound1);
		}
	}

	tagCompound.setTag("Items",  tagList);

	if(this.hasCustomInventoryName()){
		tagCompound.setString("CustomName", this.furnaceName);
	}
}

@SideOnly(Side.CLIENT)
public int getCookProgressScaled(int par1){
	return furnaceCookTime * par1 /200;
}

@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int par1){
	if(this.currentBurnTime == 0){
		this.currentBurnTime = 200;
	}
	return this.furnaceBurnTime * par1 / this.currentBurnTime;
}

public boolean isBurning(){
	return this.furnaceBurnTime > 0;
}

public void updateEntity(){
	boolean flag = this.furnaceBurnTime > 0;
	boolean flag1 = false;

	if(this.furnaceBurnTime > 0){
		--this.furnaceBurnTime;
	}

	if(!this.worldObj.isRemote){
		if(this.furnaceBurnTime == 0 && this.canSmelt()){
			this.currentBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);

			if(this.furnaceBurnTime > 0){
				flag1 = true;
				if(this.furnaceItemStacks[1] != null){
					--this.furnaceItemStacks[1].stackSize;

					if(this.furnaceItemStacks[1].stackSize == 0){
						this.furnaceItemStacks[1] = furnaceItemStacks[1].getItem().getContainerItem(this.furnaceItemStacks[1]);
					}
				}
			}
		}

		if(this.isBurning() && this.canSmelt()){
			++this.furnaceCookTime;
			if(this.furnaceCookTime == 200){
				this.furnaceCookTime = 0;
				this.smeltItem();
				flag1 = true;
			}
		}else{
			this.furnaceCookTime = 0;
		}
	}

	if(flag != this.furnaceBurnTime > 0){
		flag1 = true;
		BlastFurnace.updateBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
	}

	if(flag1){
		this.markDirty();
	}
}

private boolean canSmelt(){
	if(this.furnaceItemStacks[0] == null){
		return false;
	}else{
		ItemStack itemstack = BlastFurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
		if(itemstack == null) return false;
		if(this.furnaceItemStacks[2] == null) return true;
		if(!this.furnaceItemStacks[2].isItemEqual(itemstack)) return false;
		int result = furnaceItemStacks[2].stackSize + itemstack.stackSize;
		return result <= getInventoryStackLimit() && result <= this.furnaceItemStacks[2].getMaxStackSize();
	}
}

public void smeltItem(){
	if(this.canSmelt()){
		ItemStack itemstack = BlastFurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);

		if(this.furnaceItemStacks[2] == null){
			this.furnaceItemStacks[2] = itemstack.copy();
		}else if(this.furnaceItemStacks[2].getItem() == itemstack.getItem()){
			this.furnaceItemStacks[2].stackSize += itemstack.stackSize;
		}

		--this.furnaceItemStacks[0].stackSize;

		if(this.furnaceItemStacks[0].stackSize == 0){  // If the ItemStack contains zero or more items
			this.furnaceItemStacks[0] = null; // Set the ItemStack to null
		}
	}
}


public static int getItemBurnTime(ItemStack itemstack){
	if(itemstack == null){
		return 0;
	}else{
		Item item = itemstack.getItem();
		if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air){
			Block block = Block.getBlockFromItem(item);

			if(block == Blocks.coal_block){
				return 16000;
			}

			//if(block.getMaterial() == Material.wood{
			//	return 10;
			//}
		}
			if(item == Items.coal) return 2000;
			//if(item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("EMERALD")) return 300;
			return GameRegistry.getFuelValue(itemstack);

	}
}


public static boolean isItemFuel(ItemStack itemstack){
	return getItemBurnTime(itemstack) >0;
}

@Override
public boolean isUseableByPlayer(EntityPlayer player) {
	return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord +0.5D, (double) this.zCoord + 0.5D) <= 64.0D;
}

@Override
public void openInventory() {

}

@Override
public void closeInventory() {

}

@Override
public boolean isItemValidForSlot(int par1, ItemStack itemstack) {
	return par1 ==2 ? false :(par1 == 1 ? isItemFuel(itemstack) : true);
}

@Override
public int[] getAccessibleSlotsFromSide(int par1) {
	return par1 == 0 ? slotsBottom : (par1 == 1 ? slotsTop : slotsSides);
}

@Override
public boolean canInsertItem(int par1, ItemStack itemstack, int par3) {
	return this.isItemValidForSlot(par1, itemstack);
}

@Override
public boolean canExtractItem(int par1, ItemStack itemstack,  int par3) {
	return par3 != 0 || par1 !=1 || itemstack.getItem() == Items.bucket;
}

}

 

can someone help me figure this out?

Link to comment
Share on other sites

You fucked up this part:

 

(the direction method of BlastFurnace)

 

if(direction.func_149730_j() && direction.func_149730_j()){  //this is "if (a() && a())"
			byte0 = 3;
		}
		if(direction1.func_149730_j() && direction1.func_149730_j()){ //as is this
			byte0 = 2;
		}
		if(direction2.func_149730_j() && direction2.func_149730_j()){ //and this
			byte0 = 5;
		}
		if(direction3.func_149730_j() && direction3.func_149730_j()){ //and this
			byte0 = 4;
		}

 

Might want to look at BlockFurnace again

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

thanks for pointing that out, i have that fixed to match BlockFurnace now, but it is still not rotating to face me when i place it into the world, here is the updated file

 

BlastFurnace.java

package com.advancedtunnelbore.block;

import java.util.Random;

import com.advancedtunnelbore.lib.RefStrings;
import com.advancedtunnelbore.main.MainRegistry;
import com.advancedtunnelbore.tile_entity.TileEntityBlastFurnace;

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.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
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.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class BlastFurnace extends BlockContainer {

@SideOnly(Side.CLIENT)
private IIcon top;
@SideOnly(Side.CLIENT)
private IIcon front;

private static boolean isBurning;
private final boolean isBurning2;
private final Random random = new Random();

protected BlastFurnace(boolean isActive) {
	super(Material.rock);
	isBurning2 = isActive;
}

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconregister){
	this.blockIcon = iconregister.registerIcon(this.isBurning ? RefStrings.MODID + ":BlastFurnaceSideActive" : RefStrings.MODID + ":BlastFurnaceSideInactive" );
	this.front = iconregister.registerIcon(this.isBurning ? RefStrings.MODID + ":BlastFurnaceActive" : RefStrings.MODID + ":BlastFurnaceInactive" );
	this.top = iconregister.registerIcon(RefStrings.MODID + ":BlastFurnaceTop");
}

public IIcon getIcon(int side, int meta){
	if(side == 1){
		return top;
	}else if(side == 5){
		return front;
	}else if(side == 0){
		return top;
	}else{
		return this.blockIcon;
	}
}

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
	player.openGui(MainRegistry.modInstance, 0, world, x, y, z);
	return true;
}

public Item getItemDropped(int par1, Random random, int par3){
	return Item.getItemFromBlock(MyBlocks.blastFurnace);
}

public Item getItem(World world, int par2, int par3, int par4){
	return Item.getItemFromBlock(MyBlocks.blastFurnace);
}

@SideOnly(Side.CLIENT)	
public void onBlockAdded(World world, int x, int y, int z){
	super.onBlockAdded(world, x, y, z);
	this.direction(world, x, y, z);
}

private void direction(World world, int x, int y, int z) {
	if(!world.isRemote){
		Block direction = world.getBlock(x,  y,  z - 1);
		Block direction1 = world.getBlock(x,  y,  z + 1);
		Block direction2 = world.getBlock(x - 1,  y,  z);
		Block direction3 = world.getBlock(x + 1,  y,  z);
		byte byte0 = 3;

		if(direction.func_149730_j() && !direction1.func_149730_j()){
			byte0 = 3;
		}
		if(direction1.func_149730_j() && !direction.func_149730_j()){
			byte0 = 2;
		}
		if(direction2.func_149730_j() && !direction3.func_149730_j()){
			byte0 = 5;
		}
		if(direction3.func_149730_j() && !direction2.func_149730_j()){
			byte0 = 4;
		}

		world.setBlockMetadataWithNotify(x, y, z, byte0, 2);
	}
}

public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack){
	int direction = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) +0.5D) & 3;

	if(direction == 0){
		world.setBlockMetadataWithNotify(x, y, z, 2, 2);
	}
	if(direction == 1){
		world.setBlockMetadataWithNotify(x, y, z, 5, 2);
	}
	if(direction == 2){
		world.setBlockMetadataWithNotify(x, y, z, 3, 2);
	}
	if(direction == 3){
		world.setBlockMetadataWithNotify(x, y, z, 4, 2);
	}
	if(itemstack.hasDisplayName()){
		((TileEntityBlastFurnace) world.getTileEntity(x, y, z)).furnaceName(itemstack.getDisplayName());
	}

}

public static void updateBlockState(boolean burning, World world, int x, int y, int z){
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileentity = world.getTileEntity(x, y, z);
	isBurning = true;

	if(burning){
		world.setBlock(x, y, z, MyBlocks.blastFurnaceActive);
	}else{
		world.setBlock(x, y, z, MyBlocks.blastFurnace);
	}

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if(tileentity != null){
		tileentity.validate();world.setTileEntity(x, y, z, tileentity);
	}
}

public void breakBlock(World world, int x, int y, int z, Block block, int meta){
	if(!isBurning){
		TileEntityBlastFurnace tileentityblastfurnace = (TileEntityBlastFurnace) world.getTileEntity(x, y, z);
		if(tileentityblastfurnace != null){
			for(int i = 0; i <tileentityblastfurnace.getSizeInventory(); ++i){
				ItemStack itemstack = tileentityblastfurnace.getStackInSlot(i);

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

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

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


						itemstack.stackSize -= j;
						EntityItem entityitem = new EntityItem(world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));

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

						float f3 = 0.025F;
						entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3);
						entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3 + 0.1F);
						entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3);
						world.spawnEntityInWorld(entityitem);
					}
				}
			}
			world.func_147453_f(x, y, z, block);
		}
	}
	super.breakBlock(world, x, y, z, block, meta);
}

@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random){
	if(this.isBurning2){
		int direction = world.getBlockMetadata(x, y, z);

		float xx = (float) x + 0.5F, yy = (float) y + random.nextFloat() * 6.0f / 16.0f, zz =(float) z+ 0.5F, xx2 = random.nextFloat() * 0.3F - 0.2F, zz2 = 0.5F;

		if (direction == 4) {
			world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
			world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
		} else if (direction == 5) {
			world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
			world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
		} else if (direction == 3) {
			world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
			world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
		} else if (direction == 2) {
			world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
			world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
		}
	}
}

@Override
public TileEntity createNewTileEntity(World world, int par2) {
	return new TileEntityBlastFurnace();
}	
}

Link to comment
Share on other sites

Well, the furnace doesn't rotate to face the player either.  It specifically rotates to face away from walls.

 

So really you should be using the code in onBlockPlacedBy and not the code in onBlockAdded.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

If you want the furnace to face you you need to create a variable in your tile entity class that saves the direction of the furnace then change that variable in the on block placed method depending on the direction of the player. You then need to access the variable when retreiving the icons for the block.

Link to comment
Share on other sites

You are right diesieben using a tile entity isn't the best way of saving the data you should use the metadata like you are. While looking at the code I did notice that you aren't using the metadata when assigning block textures to the sides though so the block would always use the same texture for each side whether the metadata says the block is rotated or not. This could be your problem.

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.



×
×
  • Create New...

Important Information

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