Jump to content

Variables Behaving improperly


froschi3b

Recommended Posts

I am not sure if it's related to minecraftforge, but my problem is, i have a private variable in my tileEntity that saves the direction, i have a getter and setter for it, and all works fine.

 

But when I reload the world it returns 0, but only when called through the getBlockTexture Method, i made a check in the Block Activaton Method, and that one returns the right number.

 

Can anyone help me?

 

The TileEntity:

 

 

package flabs.mods.betterfurnaces;

import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry;

import net.minecraft.src.Block;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.FurnaceRecipes;
import net.minecraft.src.IInventory;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
/**
* The Types of Furnaces:
* 0...Iron
* 1...Gold
* 2...Diamond
* 3...Ender
* 4...Lapis
* 5...Obsidian
* 6...TNT
*/
public class TileEntityBFurnace extends TileEntity implements IInventory, ISidedInventory
{
    /**
     * The ItemStacks that hold the items currently being used in the furnace
     */
    private ItemStack[] furnaceItemStacks = new ItemStack[3];
    /**
     * If the furnace is active
     */
    public boolean isActive=false;
    
    
    //public int Type;
    private byte dir;
    
    private byte updateTimer;
    
    /**
     * The Ticks the Furnace needs to burn an item ( referring like this: Speed[Type])
     */
    public int[] Speed={150,100,50,100,100,100,25};

    /**
     * The factor by which the Fuel consumption is multiplied ( referring like this: Fuel[Type])
     */
    public static double[] Fuel={0.75,0.5,0.25,1,1,0.5,0.03125};
    /**
     * Ore Handling Variables for the Obsidian Furnace
     */
public List<ItemStack> ores=new ArrayList <ItemStack>();

    /** The number of ticks that the furnace will keep burning */
    public int furnaceBurnTime = 0;

    /**
     * The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for
     */
    public int currentItemBurnTime = 0;

    /** The number of ticks that the current item has been cooking for */
    public int furnaceCookTime = 0;
    
    public TileEntityBFurnace(){
    	//loadOres();
    }

    /**
     * Returns the number of slots in the inventory.
     */
    @Override
    public int getSizeInventory()
    {
        return this.furnaceItemStacks.length;
    }

    /**
     * Returns the stack in slot i
     */
    @Override
    public ItemStack getStackInSlot(int par1)
    {
        return this.furnaceItemStacks[par1];
    }

    /**
     * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
     * stack.
     */
    @Override
    public ItemStack decrStackSize(int par1, int par2)
    {
        if (this.furnaceItemStacks[par1] != null)
        {
            ItemStack var3;

            if (this.furnaceItemStacks[par1].stackSize <= par2)
            {
                var3 = this.furnaceItemStacks[par1];
                this.furnaceItemStacks[par1] = null;
                return var3;
            }
            else
            {
                var3 = this.furnaceItemStacks[par1].splitStack(par2);

                if (this.furnaceItemStacks[par1].stackSize == 0)
                {
                    this.furnaceItemStacks[par1] = null;
                }

                return var3;
            }
        }
        else
        {
            return null;
        }
    }

    /**
     * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
     * like when you close a workbench GUI.
     */
    @Override
    public ItemStack getStackInSlotOnClosing(int par1)
    {
        if (this.furnaceItemStacks[par1] != null)
        {
            ItemStack var2 = this.furnaceItemStacks[par1];
            this.furnaceItemStacks[par1] = null;
            return var2;
        }
        else
        {
            return null;
        }
    }

    /**
     * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
     */
    @Override
    public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
    {
        this.furnaceItemStacks[par1] = par2ItemStack;

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

    /**
     * Returns the name of the inventory.
     */
    @Override
    public String getInvName()
    {
        return "container.furnace";
    }

    /**
     * Reads a tile entity from NBT.
     */
    @Override
    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.readFromNBT(par1NBTTagCompound);
        NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
        this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];

        for (int var3 = 0; var3 < var2.tagCount(); ++var3)
        {
            NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
            byte var5 = var4.getByte("Slot");

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

        this.furnaceBurnTime = par1NBTTagCompound.getShort("BurnTime");
        this.furnaceCookTime = par1NBTTagCompound.getShort("CookTime");
        this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
        this.isActive = par1NBTTagCompound.getBoolean("isActive");
        this.setDir(par1NBTTagCompound.getByte("Dire"));
        //loadOres();
    }
    public void loadOres(){
    	System.out.println("Adding Ores on Better Furnace: " + xCoord +", "+ yCoord+", "+zCoord);
	// Ore Handling for the Obsidian Furnace
    	ores.add(new ItemStack(Block.oreCoal));
    	ores.add(new ItemStack(Block.oreDiamond));
    	ores.add(new ItemStack(Block.oreGold));
    	ores.add(new ItemStack(Block.oreIron));
    	ores.add(new ItemStack(Block.oreLapis,);
    	ores.add(new ItemStack(Block.oreRedstone,4));
    	List<ItemStack> oreTin=OreDictionary.getOres("oreTin");
    	List<ItemStack> oreCopper=OreDictionary.getOres("oreCopper");
    	List<ItemStack> oreSilver=OreDictionary.getOres("oreSilver");
    	if (oreTin!=null){
    		int i=0;
        	while (i<oreTin.size()){
        		ItemStack is=oreTin.get(i).copy();
        		is.stackSize=2;
        		ores.add(is);
        		i++;
        	}
    	}
    	if (oreCopper!=null){
    		int i=0;
        	while (i<oreCopper.size()){
        		ItemStack is=oreCopper.get(i).copy();
        		is.stackSize=2;
        		ores.add(is);
        		i++;
        	}
    	}
    	if (oreSilver!=null){
    		int i=0;
        	while (i<oreSilver.size()){
        		ItemStack is=oreSilver.get(i).copy();
        		is.stackSize=2;
        		ores.add(is);
        		i++;
        	}
    	}
    }

    /**
     * Writes a tile entity to NBT.
     */
    @Override
    public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.writeToNBT(par1NBTTagCompound);
        par1NBTTagCompound.setShort("BurnTime", (short)this.furnaceBurnTime);
        par1NBTTagCompound.setShort("CookTime", (short)this.furnaceCookTime);
        par1NBTTagCompound.setBoolean("isActive",this.isActive);
        par1NBTTagCompound.setByte("Dire",this.getDir());
        NBTTagList var2 = new NBTTagList();

        for (int var3 = 0; var3 < this.furnaceItemStacks.length; ++var3)
        {
            if (this.furnaceItemStacks[var3] != null)
            {
                NBTTagCompound var4 = new NBTTagCompound();
                var4.setByte("Slot", (byte)var3);
                this.furnaceItemStacks[var3].writeToNBT(var4);
                var2.appendTag(var4);
            }
        }

        par1NBTTagCompound.setTag("Items", var2);
        
    }

    /**
     * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't
     * this more of a set than a get?*
     */
    @Override
    public int getInventoryStackLimit()
    {
        return 64;
    }

    /**
     * Returns an integer between 0 and the passed value representing how close the current item is to being completely
     * cooked
     */
    public int getCookProgressScaled(int par1)
    {
        return this.furnaceCookTime * par1 / this.Speed[getType()];
    }

    /**
     * Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel
     * item, where 0 means that the item is exhausted and the passed value means that the item is fresh
     */
    public int getBurnTimeRemainingScaled(int par1)
    {
        if (this.currentItemBurnTime == 0)
        {
            this.currentItemBurnTime = this.Speed[getType()];
        }

        return this.furnaceBurnTime * par1 / this.currentItemBurnTime;
    }

    /**
     * Returns true if the furnace is currently burning
     */
    public boolean isBurning()
    {
        return this.furnaceBurnTime > 0;
    }

    /**
     * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
     * ticks and creates a new spawn inside its implementation.
     */
    @Override
    public void updateEntity()
    {
        boolean var1 = this.furnaceBurnTime > 0;
        boolean var2 = false;
        
        if (updateTimer < 10){
        	this.updateTimer++;
        }else if (this.updateTimer==10){
        	this.getWorldObj().notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID);
        	this.getWorldObj().updateAllLightTypes(xCoord, yCoord, zCoord);
        	this.updateTimer++;
        }
        
        if (this.furnaceBurnTime > 0)
        {
            --this.furnaceBurnTime;
        }

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

                if (this.furnaceBurnTime > 0)
                {
                    var2 = true;

                    if (this.furnaceItemStacks[1] != null)
                    {
                        --this.furnaceItemStacks[1].stackSize;

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

            if (this.isBurning() && this.canSmelt())
            {
                ++this.furnaceCookTime;

                if (this.furnaceCookTime == this.Speed[getType()])
                {
                    this.furnaceCookTime = 0;
                    this.smeltItem();
                    var2 = true;
                }
            }
            else
            {
                this.furnaceCookTime = 0;
            }

            if (var1 != this.furnaceBurnTime > 0)
            {
                var2 = true;
                if (this.furnaceBurnTime > 0){
                	this.isActive=true;
                	this.worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
                	this.worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
                }else{
                	this.isActive=false;
                	this.worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
                	this.worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
                }
            }
        }

        if (var2)
        {
            this.onInventoryChanged();
        }
    }

    /**
     * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
     */
    private boolean canSmelt()
    {
        if (this.furnaceItemStacks[0] == null)
        {
            return false;
        }
        else
        {
            ItemStack var1 = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
            if (var1 == null) return false;
            if (this.furnaceItemStacks[2] == null) return true;
            if (!this.furnaceItemStacks[2].isItemEqual(var1)) return false;
            int result = furnaceItemStacks[2].stackSize + var1.stackSize;
            return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize());
        }
    }

    /**
     * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
     */
    public void smeltItem()
    {
        if (this.canSmelt())
        {
            ItemStack is = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
            ItemStack var1=is.copy();
            if (this.getType()==5){
                if (this.ores.size()==0){
                	loadOres();
                }

            	System.out.println(this.ores.size());
            	int i=0;
            	while (i<this.ores.size()){
            		if (this.furnaceItemStacks[0].itemID==this.ores.get(i).itemID){
            			var1.stackSize=2;
            		}
        			System.out.println(this.furnaceItemStacks[0].itemID + ", " + this.ores.get(i).itemID);
        			i++;
            	}
            }

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

            --this.furnaceItemStacks[0].stackSize;

            if (this.furnaceItemStacks[0].stackSize <= 0)
            {
                this.furnaceItemStacks[0] = null;
            }
        }
    }

    /**
     * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
     * fuel
     */
    public int getItemBurnTime(ItemStack par1ItemStack)
    {
        if (par1ItemStack == null)
        {
            return 0;
        }
        else
        {
            int var1 = par1ItemStack.getItem().shiftedIndex;
            
            if (var1 < 256 && Block.blocksList[var1].blockMaterial == Material.wood) return (int) Math.ceil(300*Fuel[getType()]);
            if (var1 == Item.stick.shiftedIndex) return (int) Math.ceil(100*Fuel[getType()]);
            if (var1 == Item.coal.shiftedIndex) return (int) Math.ceil(1600*Fuel[getType()]);
            if (var1 == Item.bucketLava.shiftedIndex) return (int) Math.ceil(20000*Fuel[getType()]);
            if (var1 == Block.sapling.blockID) return (int) Math.ceil(100*Fuel[getType()]);
            if (var1 == Item.blazeRod.shiftedIndex) return (int) Math.ceil(2400*Fuel[getType()]);
            int ret = GameRegistry.getFuelValue(par1ItemStack);
            if (ret > 0) 
            {
                return (int) Math.ceil(ret*Fuel[getType()]);
            }
            return 0;
        }
    }

    /**
     * Return true if item is a fuel source (getItemBurnTime() > 0).
     */
    public boolean isItemFuel(ItemStack par0ItemStack)
    {
        return getItemBurnTime(par0ItemStack) > 0;
    }

    /**
     * Do not make give this method the name canInteractWith because it clashes with Container
     */
    @Override
    public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
    {
        return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
    }

    @Override
    public void openChest() {}

    @Override
    public void closeChest() {}

    @Override
    public int getStartInventorySide(ForgeDirection side)
    {
        if (side == ForgeDirection.DOWN) return 1;
        if (side == ForgeDirection.UP) return 0; 
        return 2;
    }

    @Override
    public int getSizeInventorySide(ForgeDirection side)
    {
        return 1;
    }
    public byte getDir(){
    	if (this.dir==0){return 3;}
    	return this.dir;
    }
    public void setDir(byte b){
    	System.out.println("setting dir to"+b);
    	this.dir=b;
    }
    public int getType(){
    	//System.out.println("Test"+Type);
    	return this.getBlockMetadata();
    }
}

 

 

The Block:

 

package flabs.mods.betterfurnaces;

import java.util.*;

import flabs.mods.betterfurnaces.client.GuiBFurnace;

import net.minecraft.src.Block;
import net.minecraft.src.BlockContainer;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.EntityItem;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import net.minecraft.src.MathHelper;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;

public class BlockBFurnace extends BlockContainer
{
    /**
     * Is the random generator used by furnace to drop the inventory contents in random directions.
     */
    private Random furnaceRand = new Random();

    protected BlockBFurnace(int i)
    {
        super(i, Material.iron);
        this.blockIndexInTexture = 0;
        this.setCreativeTab(CreativeTabs.tabDecorations);
    }

    @Override
    public void addCreativeItems(ArrayList itemList)
    {
    	for(int l1 = 0; l1 < BetterFurnaces.furnaces.length; l1++)
        {
                itemList.add(new ItemStack(this, 1, l1));
        }
    }
    /**
     * Returns the Metadata of the item to drop on destruction.
     */
    @Override
    public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
    {
    	return ;
    }

    /**
     * Called whenever the block is added into the world. Args: world, x, y, z
     */
    @Override
    public void onBlockAdded(World world, int i, int j, int k)
    {
        super.onBlockAdded(world, i, j, k);
        System.out.println("WEEEEEEEEEEEEEEEEEEEEEEEEE");
        this.setDefaultDirection(world, i, j, k);
    }
    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
    {
        for (int var4 = 0; var4 < BetterFurnaces.furnaces.length; ++var4)
        {
            par3List.add(new ItemStack(par1, 1, var4));
        }
    }
    
    @Override
    public int getLightValue(IBlockAccess world,int  x,int y,int z){
    	TileEntityBFurnace tebf=getTileEntityaround(world,x,y,z);
    	if (tebf!=null){
        	if (tebf.isActive){
        		return 14;
        	}
    	}
    	return 0;
    }
    /**
     * Returns one of the TileEntityBFurnace around it.
     * Args: IBlockAccess,x,y,z
     */
    private TileEntityBFurnace getTileEntityaround(IBlockAccess world,int  x,int y,int z){
    	TileEntity te[]={world.getBlockTileEntity(x, y, z)
    			,world.getBlockTileEntity(x+1, y, z)
    			,world.getBlockTileEntity(x-1, y, z)
    			,world.getBlockTileEntity(x, y+1, z)
    			,world.getBlockTileEntity(x, y-1, z)
    			,world.getBlockTileEntity(x, y, z+1)
    			,world.getBlockTileEntity(x, y, z-1)};
    	int i=0;
    	while(i<te.length){
        	if ((te[i]!=null) && (te[i] instanceof TileEntityBFurnace)){
        		return (TileEntityBFurnace) te[i];
        	}
        	i++;
        }
    	return null;
    }
    

    /**
     * set a blocks direction
     */
    private void setDefaultDirection(World world, int i, int j, int k)
    {
        if (!world.isRemote)
        {
            int var5 = world.getBlockId(i, j, k - 1);
            int var6 = world.getBlockId(i, j, k + 1);
            int var7 = world.getBlockId(i - 1, j, k);
            int var8 = world.getBlockId(i + 1, j, k);
            byte var9 = 3;

            if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6])
            {
                var9 = 3;
            }

            if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5])
            {
                var9 = 2;
            }

            if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8])
            {
                var9 = 5;
            }

            if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7])
            {
                var9 = 4;
            }
            ((TileEntityBFurnace)world.getBlockTileEntity(i, j, k)).setDir(var9);
        }
    }

    /**
     * Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
     */
    @Override
    public int getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l)
    {
    	TileEntityBFurnace tebf=(TileEntityBFurnace)iblockaccess.getBlockTileEntity(i, j, k);
    	if (tebf==null){return 0;}
        if (l == 1)
        {
            return tebf.getType();
        }
        else if (l == 0)
        {
            return tebf.getType();
        }
        else
        {
            int var6 = tebf.getDir();
            if (var6==0){
            	return 0;
            }
            if (l!=var6){
            	return tebf.getType()+16;
            }
            else if (tebf.isActive)
            {
            	return tebf.getType() +48;
            }else{
            	return tebf.getType()+32;
            }
        }
    }

    /**
     * A randomly called display update to be able to add particles or other items for display
     */
    @Override
    public void randomDisplayTick(World world, int i, int j, int k, Random random)
    {
    	TileEntityBFurnace tebf=(TileEntityBFurnace)world.getBlockTileEntity(i, j, k);
        if (tebf.isActive)
        {
            int var6 = tebf.getDir();
            float var7 = (float)i + 0.5F;
            float var8 = (float)j + 0.0F + random.nextFloat() * 6.0F / 16.0F;
            float var9 = (float)k + 0.5F;
            float var10 = 0.52F;
            float var11 = random.nextFloat() * 0.6F - 0.3F;

            if (var6 == 4)
            {
                world.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
                world.spawnParticle("flame", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 5)
            {
                world.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
                world.spawnParticle("flame", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 2)
            {
                world.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
                world.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D);
            }
            else if (var6 == 3)
            {
                world.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
                world.spawnParticle("flame", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D);
            }
        }
    }

    /**
     * Returns the block texture based on the side being looked at.  Args: side
     */
    @Override
    public int getBlockTextureFromSideAndMetadata(int i,int j)
    {
    	if (i==1 || i==0){return j;}
    	if (i==3){return j+32;}
        return j+16;
    }

    /**
     * Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the
     * block.
     */
    @Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int i1, float f1, float f2, float f3) {
	TileEntity te = world.getBlockTileEntity(i, j, k);

	if (te==null|| !(te instanceof TileEntityBFurnace)){
		return true;
	}
	if (world.isRemote){
		return true;
	}
	TileEntityBFurnace tebf = (TileEntityBFurnace)te;
	byte b=tebf.getDir();
	System.out.println("TileEntity at: "+i+", "+j+", "+k+"; activated. Dir: "+b+" Type: "+tebf.getType());
	tebf.setDir(b);
	player.openGui(BetterFurnaces.instance,0, world, i,j,k);
	return true;
}

    /**
     * Called when the block is placed in the world.
     */
    @Override
    public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
    {
        int var6 = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
        TileEntityBFurnace tebf=(TileEntityBFurnace)world.getBlockTileEntity(i, j, k);
        
        if (var6 == 0)
        {
            tebf.setDir((byte) 2);
        }

        if (var6 == 1)
        {
            tebf.setDir((byte) 5);
        }

        if (var6 == 2)
        {
        	tebf.setDir((byte) 3);
        }

        if (var6 == 3)
        {
        	tebf.setDir((byte) 4);
        }
    }

    /**
     * Called whenever the block is removed.
     */
    @Override
    public void breakBlock(World world, int i, int j, int k,int m,int n)
    {
            TileEntityBFurnace var5 = (TileEntityBFurnace)world.getBlockTileEntity(i, j, k);

            if (var5 != null)
            {
            	float var8 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
            	float var9 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
            	float var10 = this.furnaceRand.nextFloat() * 0.8F + 0.1F;
                float var13 = 0.05F;
            	
            	EntityItem BlockDrop = new EntityItem(world, (double)((float)i + var8), (double)((float)j + var9), (double)((float)k + var10), new ItemStack(BetterFurnaces.bfurnace, 1, var5.getType()));

                BlockDrop.motionX = (double)((float)this.furnaceRand.nextGaussian() * var13);
                BlockDrop.motionY = (double)((float)this.furnaceRand.nextGaussian() * var13 + 0.2F);
                BlockDrop.motionZ = (double)((float)this.furnaceRand.nextGaussian() * var13);
            	
            	world.spawnEntityInWorld(BlockDrop);
            	
                for (int var6 = 0; var6 < var5.getSizeInventory(); ++var6)
                {
                    ItemStack var7 = var5.getStackInSlot(var6);

                    if (var7 != null)
                    {
                        
                        while (var7.stackSize > 0)
                        {
                            int var11 = this.furnaceRand.nextInt(21) + 10;

                            if (var11 > var7.stackSize)
                            {
                                var11 = var7.stackSize;
                            }

                            var7.stackSize -= var11;
                            EntityItem var12 = new EntityItem(world, (double)((float)i + var8), (double)((float)j + var9), (double)((float)k + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage()));

                            if (var7.hasTagCompound())
                            {
                                var12.item.setTagCompound((NBTTagCompound)var7.getTagCompound().copy());
                            }
                            
                            var12.motionX = (double)((float)this.furnaceRand.nextGaussian() * var13);
                            var12.motionY = (double)((float)this.furnaceRand.nextGaussian() * var13 + 0.2F);
                            var12.motionZ = (double)((float)this.furnaceRand.nextGaussian() * var13);
                            world.spawnEntityInWorld(var12);
                        }
                    }
                }
            }

        super.breakBlock(world, i, j, k,m,n);
    }
    @Override
    public String getTextureFile(){
    	return "/flabs/mods/betterfurnaces/sprites/BFurnaces.png";
    }

    public TileEntity createNewTileEntity(World world, int metadata)
    {
    	TileEntityBFurnace tebf =new TileEntityBFurnace();
    	return tebf;
    }
@Override
public TileEntity createNewTileEntity(World var1) {
        return new TileEntityBFurnace();
}
}

 

Link to comment
Share on other sites

I think your problem is that the tileEntity on the server will read your 'Dire' from the NBT system, but you need to send a package to make sure your client tileEntity knows the direction as well.

 

Easy way to test whether this is the case is to add the following code to your tileEntity's entityUpdate() method:

Side side = FMLCommonHandler.instance().getEffectiveSide();
System.out.println("The direction is " + this.getDir() + " in " + side);

Make sure you only have a single copy of your tileEntity up in the world, because it'll be spamming a lot of System.out messages once there's a BFurnace. One will say "The direction is ? in SERVER" the other will say "The direction is ? in CLIENT". If ? is not the same in both cases, you'll have found 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.

Announcements



×
×
  • Create New...

Important Information

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