Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Unable to move items while in custom furance gui.


Recommended Posts

I've look everywhere and i see people said @NetworkMod...but that is not longer used.

I was able to make my funace to open gui and show slots for fuel,smelting item and smelting result where i wanted.

Thing is when i enter gui with right click i can't move any items while im in gui....that dose not allow me to see if my furnace is working. Outside works fine...

I can shift click ore into coresponding slot that will be smelted but i can't move coal or any item to fuel slot...dus making me unable to see if furnace is working.

 

Here is Block itself:

package com.expansion.blocks;

import java.util.Random;

import com.expansion.main.Main;
import com.expansion.tileEntities.TileEntityGrinder;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockGrinder extends BlockContainer {

public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
private final boolean isBurning;
private static boolean keepInventory;

protected BlockGrinder(Boolean IsBurning) {
	super(Material.rock);
	isBurning = IsBurning;
}


@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {

	return new TileEntityGrinder();
}

public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return Item.getItemFromBlock(Blocks.furnace);
    }

    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
    {
        this.setDefaultFacing(worldIn, pos, state);
    }

    private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
    {
        if (!worldIn.isRemote)
        {
            Block block = worldIn.getBlockState(pos.north()).getBlock();
            Block block1 = worldIn.getBlockState(pos.south()).getBlock();
            Block block2 = worldIn.getBlockState(pos.west()).getBlock();
            Block block3 = worldIn.getBlockState(pos.east()).getBlock();
            EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

            if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
            {
                enumfacing = EnumFacing.SOUTH;
            }
            else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
            {
                enumfacing = EnumFacing.NORTH;
            }
            else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
            {
                enumfacing = EnumFacing.EAST;
            }
            else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
            {
                enumfacing = EnumFacing.WEST;
            }

            worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
        }
    }
    
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
    { 
    	if (!worldIn.isRemote)
        {
            return true;
        }
        else
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityGrinder)
            {
            	 playerIn.openGui(Main.instance, BlockList.GuiGrinder, worldIn, pos.getX(), pos.getY(), pos.getZ());
            }
           
            return true;
        }
        
    }
    
    public static void setState(boolean active, World worldIn, BlockPos pos)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        TileEntity tileentity = worldIn.getTileEntity(pos);
        keepInventory = true;

        if (active)
        {
            worldIn.setBlockState(pos, BlockList.GrinderActive.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);           
        }
        else
        {
            worldIn.setBlockState(pos, BlockList.GrinderIdle.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);       
        }

        keepInventory = false;

        if (tileentity != null)
        {
            tileentity.validate();
            worldIn.setTileEntity(pos, tileentity);
        }
    }
    
    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
    {
        return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
    }
    
    public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
    {
        worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);

        if (stack.hasDisplayName())
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityGrinder)
            {
                ((TileEntityGrinder)tileentity).setCustomInventoryName(stack.getDisplayName());
            }
        }
    }
    
    public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
    {
        if (!keepInventory)
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityGrinder)
            {
                InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityGrinder)tileentity);
                worldIn.updateComparatorOutputLevel(pos, this);
            }
        }

        super.breakBlock(worldIn, pos, state);
    }
    
    public boolean hasComparatorInputOverride()
    {
        return true;
    }

    public int getComparatorInputOverride(World worldIn, BlockPos pos)
    {
        return Container.calcRedstone(worldIn.getTileEntity(pos));
    }

    @SideOnly(Side.CLIENT)
    public Item getItem(World worldIn, BlockPos pos)
    {
        return Item.getItemFromBlock(BlockList.GrinderIdle);
    }
    
    public int getRenderType()
    {
        return 3;
    }
    
    @SideOnly(Side.CLIENT)
    public IBlockState getStateForEntityRender(IBlockState state)
    {
        return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
    }

    
    public IBlockState getStateFromMeta(int meta)
    {
        EnumFacing enumfacing = EnumFacing.getFront(meta);

        if (enumfacing.getAxis() == EnumFacing.Axis.Y)
        {
            enumfacing = EnumFacing.NORTH;
        }

        return this.getDefaultState().withProperty(FACING, enumfacing);
    }
    
    public int getMetaFromState(IBlockState state)
    {
        return ((EnumFacing)state.getValue(FACING)).getIndex();
    }

    protected BlockState createBlockState()
    {
        return new BlockState(this, new IProperty[] {FACING});
    }

    
    static final class SwitchEnumFacing
    {
        static final int[] FACING_LOOKUP = new int[EnumFacing.values().length];      
        static
        {
            try
            {
                FACING_LOOKUP[EnumFacing.WEST.ordinal()] = 1;
            }
            catch (NoSuchFieldError var4)
            {
                ;
            }

            try
            {
                FACING_LOOKUP[EnumFacing.EAST.ordinal()] = 2;
            }
            catch (NoSuchFieldError var3)
            {
                ;
            }

            try
            {
                FACING_LOOKUP[EnumFacing.NORTH.ordinal()] = 3;
            }
            catch (NoSuchFieldError var2)
            {
                ;
            }

            try
            {
                FACING_LOOKUP[EnumFacing.SOUTH.ordinal()] = 4;
            }
            catch (NoSuchFieldError var1)
            {
                ;
            }
        }
    }

}

 

Container:

package com.expansion.containers;

import com.expansion.tileEntities.TileEntityGrinder;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotFurnaceFuel;
import net.minecraft.inventory.SlotFurnaceOutput;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ContainerGrinder extends Container {

private final IInventory tileFurnace;
    private int LastCookTime;
    private int LastFurnaceSpeed;
    private int LastBurnTime;
    private int LastItemBurnTime;

public ContainerGrinder(InventoryPlayer playerInventory, TileEntityGrinder tileEntityGrinder) {
	this.tileFurnace = playerInventory;
	//Slot for Smelting items
	this.addSlotToContainer(new Slot(tileEntityGrinder, 0, 56, 17));

	//Slot for Fuel
	this.addSlotToContainer(new SlotFurnaceFuel(tileEntityGrinder, 1, 56, 53));

	//Smelt Item slot
	this.addSlotToContainer(new SlotFurnaceOutput(playerInventory.player, tileEntityGrinder, 2, 115, 35));

	//Players Inventory
	for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 9; ++j)
            {
                this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
            }
        }
	//Players hotbar
        for (int i = 0; i < 9; ++i)
        {
            this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 142));
        }
}

@Override
public boolean canInteractWith(EntityPlayer playerIn) {

	return this.tileFurnace.isUseableByPlayer(playerIn);
}

public void addCraftingToCrafters(ICrafting listener)
    {
        super.addCraftingToCrafters(listener);
        listener.func_175173_a(this, this.tileFurnace);
    }

    /**
     * Looks for changes made in the container, sends them to every listener.
     */
    public void detectAndSendChanges()
    {
        super.detectAndSendChanges();

        for (int i = 0; i < this.crafters.size(); ++i)
        {
            ICrafting icrafting = (ICrafting)this.crafters.get(i);

            if (this.LastItemBurnTime != this.tileFurnace.getField(2))
            {
                icrafting.sendProgressBarUpdate(this, 2, this.tileFurnace.getField(2));
            }

            if (this.LastBurnTime != this.tileFurnace.getField(0))
            {
                icrafting.sendProgressBarUpdate(this, 0, this.tileFurnace.getField(0));
            }

            if (this.LastCookTime != this.tileFurnace.getField(1))
            {
                icrafting.sendProgressBarUpdate(this, 1, this.tileFurnace.getField(1));
            }

            if (this.LastFurnaceSpeed != this.tileFurnace.getField(3))
            {
                icrafting.sendProgressBarUpdate(this, 3, this.tileFurnace.getField(3));
            }
        }

        this.LastItemBurnTime = this.tileFurnace.getField(2);
        this.LastBurnTime = this.tileFurnace.getField(0);
        this.LastCookTime = this.tileFurnace.getField(1);
        this.LastFurnaceSpeed = this.tileFurnace.getField(3);
    }
    
    @SideOnly(Side.CLIENT)
    public void updateProgressBar(int id, int data)
    {
        this.tileFurnace.setField(id, data);
    }
    
    public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
    {
        ItemStack itemstack = null;
        Slot slot = (Slot)this.inventorySlots.get(index);

        if (slot != null && slot.getHasStack())
        {
            ItemStack itemstack1 = slot.getStack();
            itemstack = itemstack1.copy();

            if (index == 2)
            {
                if (!this.mergeItemStack(itemstack1, 3, 39, true))
                {
                    return null;
                }

                slot.onSlotChange(itemstack1, itemstack);
            }
            else if (index != 1 && index != 0)
            {
                if (FurnaceRecipes.instance().getSmeltingResult(itemstack1) != null)
                {
                    if (!this.mergeItemStack(itemstack1, 0, 1, false))
                    {
                        return null;
                    }
                }
                else if (TileEntityFurnace.isItemFuel(itemstack1))
                {
                    if (!this.mergeItemStack(itemstack1, 1, 2, false))
                    {
                        return null;
                    }
                }
                else if (index >= 3 && index < 30)
                {
                    if (!this.mergeItemStack(itemstack1, 30, 39, false))
                    {
                        return null;
                    }
                }
                else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
                {
                    return null;
                }
            }
            else if (!this.mergeItemStack(itemstack1, 3, 39, false))
            {
                return null;
            }

            if (itemstack1.stackSize == 0)
            {
                slot.putStack((ItemStack)null);
            }
            else
            {
                slot.onSlotChanged();
            }

            if (itemstack1.stackSize == itemstack.stackSize)
            {
                return null;
            }

            slot.onPickupFromSlot(playerIn, itemstack1);
        }

        return itemstack;
    }

}

 

GuiHandler:

package com.expansion.handler;

import com.expansion.blocks.BlockList;
import com.expansion.containers.ContainerGrinder;
import com.expansion.gui.GuiGrinder;
import com.expansion.tileEntities.TileEntityGrinder;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;

public class GuiHandler implements IGuiHandler{

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {

	BlockPos pos = new BlockPos(x,y,z);
	TileEntity tileEntity = world.getTileEntity(pos);

        if(tileEntity != null)
        {
        	switch (ID)
        	{
        		case BlockList.GuiGrinder: return new ContainerGrinder(player.inventory,(TileEntityGrinder)tileEntity);
        	}


	}


	return null;
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {

	BlockPos pos = new BlockPos(x,y,z);
	TileEntity tileEntity = world.getTileEntity(pos);

        if(tileEntity != null)
        {
        	switch (ID)
        	{
        		case BlockList.GuiGrinder: return new GuiGrinder(player.inventory,(TileEntityGrinder)tileEntity);
        	}


	}
	return null;
}

}

 

TileEntity:

package com.expansion.tileEntities;

import com.expansion.blocks.BlockGrinder;
import com.expansion.containers.ContainerGrinder;

import net.minecraft.block.Block;
import net.minecraft.block.BlockFurnace;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerFurnace;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.inventory.SlotFurnaceFuel;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.gui.IUpdatePlayerListBox;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class TileEntityGrinder 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[] slots = new ItemStack[3];
    public int furnaceSpeed;
    public int burnTime;
    public int currentItemBurnTime;
    public int cookTime;
    private String furnaceCustomName;

@Override
public int getSizeInventory() 
{

	return this.slots.length;
}

@Override
public ItemStack getStackInSlot(int index)
{

	return this.slots[index];
}

@Override
public ItemStack decrStackSize(int index, int count)
{

	if (this.slots[index] != null)
        {
            ItemStack itemstack;

            if (this.slots[index].stackSize <= count)
            {
                itemstack = this.slots[index];
                this.slots[index] = null;
                return itemstack;
            }
            else
            {
                itemstack = this.slots[index].splitStack(count);

                if (this.slots[index].stackSize == 0)
                {
                    this.slots[index] = null;
                }

                return itemstack;
            }
        }
        else
        {
            return null;
        }
}

@Override
public ItemStack getStackInSlotOnClosing(int index) 
{

	if (this.slots[index] != null)
        {
            ItemStack itemstack = this.slots[index];
            this.slots[index] = null;
            return itemstack;
        }
        else
        {
            return null;
        }
}

@Override
public void setInventorySlotContents(int index, ItemStack stack)
{

	boolean flag = stack != null && stack.isItemEqual(this.slots[index]) && ItemStack.areItemStackTagsEqual(stack, this.slots[index]);
        this.slots[index] = stack;

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

        if (index == 0 && !flag)
        {
            
            this.cookTime = 0;
            this.markDirty();
        }

}




@Override
public int getInventoryStackLimit() 
{

	return 64;
}

@Override
public boolean isUseableByPlayer(EntityPlayer player) 
{

	 return true;
}

@Override
public void openInventory(EntityPlayer player) {}
@Override
public void closeInventory(EntityPlayer player) {}

@Override
public boolean isItemValidForSlot(int index, ItemStack stack)
{

	return index == 2 ? false : (index != 1 ? true : isItemFuel(stack) || SlotFurnaceFuel.isBucket(stack));
}

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


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.wooden_slab)            
                    return 150;               
                if (block.getMaterial() == Material.wood)               
                    return 300;              
                if (block == Blocks.coal_block)
                    return 16000;
            }

            if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200;
            if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200;
            if (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD")) return 200;
            if (item == Items.stick) return 100;
            if (item == Items.coal) return 1600;
            if (item == Items.lava_bucket) return 20000;
            if (item == Item.getItemFromBlock(Blocks.sapling)) return 100;
            if (item == Items.blaze_rod) return 2400;
            return GameRegistry.getFuelValue(itemStack);
        }
    }


@Override
public int getField(int id)
{
	switch(id)
	{
	case 1: return this.burnTime;
	case 2: return this.cookTime;
	case 3: return this.currentItemBurnTime;
	case 4: return this.furnaceSpeed;
	default: return 0;

	}
}

@Override
public void setField(int id, int value) 
{
	switch(id)
	{
	case 1: this.burnTime = value;
	case 2: this.cookTime = value;
	case 3: this.currentItemBurnTime = value;
	case 4: this.furnaceSpeed = 150;


	}

}

@Override
public int getFieldCount()
{		
	return 4;
}

@Override
public void clear() 
{

	for (int i = 0; i < this.slots.length; ++i)
        {
            this.slots[i] = null;
        }

}

@Override
public String getName()
{

	return this.hasCustomName() ? furnaceCustomName : "container.Grinder";
}

@Override
public boolean hasCustomName()
{

	return this.furnaceCustomName != null && this.furnaceCustomName.length() > 0;
}

@Override
public IChatComponent getDisplayName() 
{

	return new ChatComponentText(this.getName());
}

public int[] getSlotsForFace(EnumFacing side) 
{

	return side == EnumFacing.DOWN ? slotsBottom : (side == EnumFacing.UP ? slotsTop : slotsSides);
}

public boolean canInsertItem(int index, ItemStack itemStack, EnumFacing direction) {

	return this.isItemValidForSlot(index, itemStack);
}

public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {

	if (direction == EnumFacing.DOWN && index == 1)
        {
            Item item = stack.getItem();

            if (item != Items.water_bucket && item != Items.bucket)
            {
                return false;
            }
        }
	return true;
}

public void update()
{
	boolean flag = this.burnTime > 0;
	boolean flag1 = false;

	if(this.burnTime > 0)
	{
		this.burnTime --;

	}
	if(this.worldObj.isRemote)
	{
		if(this.burnTime == 0 && this.canSmelt())
		{
			this.currentItemBurnTime = this.burnTime = getItemBurnTime(this.slots[1]);

			if(this.isBurning())
			{
				flag1 = true;

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

					if(this.slots[1].stackSize == 0)
					{
						this.slots[1] = this.slots[1].getItem().getContainerItem(this.slots[1]);
					}
				}
			}
		}
	}
	if(this.isBurning() && this.canSmelt())
	{
		this.cookTime++;

		if(this.cookTime == this.furnaceSpeed)
		{
			this.cookTime = 0;
			this.canSmelt();
			flag1 = true;
		}
		else
		{
			this.cookTime = 0;
		}
		if(flag != this.isBurning())
		{
			flag1 = true;
			BlockGrinder.setState(this.isBurning(), this.worldObj, this.pos);
		}
	}
	if(flag1)
	{
		this.markDirty();
	}
}

private boolean canSmelt()	
{
	if(this.slots[0] == null)
	{
		return false;
	}
	else
	{
		ItemStack itemStack = FurnaceRecipes.instance().getSmeltingResult(this.slots[0]);							
		if(itemStack == null) return false;
		if(this.slots[2] == null) this.slots[2] = itemStack.copy();
		else if(!this.slots[2].isItemEqual(itemStack)) return false;

		int result = this.slots[2].stackSize + itemStack.stackSize;

		return (result <= this.getInventoryStackLimit() && result <= itemStack.getMaxStackSize());
	}
}
public void smeltItem()
{
	if(this.canSmelt())
	{
		ItemStack itemStack = FurnaceRecipes.instance().getSmeltingResult(this.slots[0]);
		if(this.slots[2] == null) this.slots[2] = itemStack.copy();

		else if(!this.slots[2].isItemEqual(itemStack))
		this.slots[2].stackSize += itemStack.stackSize;
		this.slots[0].stackSize--;

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

private boolean isBurning() 
{

	return burnTime > 0;
}

public void setCustomInventoryName(String displayName) {

	 this.furnaceCustomName = displayName;
}

public void readFromNBT(NBTTagCompound compound)
    {
        super.readFromNBT(compound);
        NBTTagList nbttaglist = compound.getTagList("Items", 10);
        this.slots = new ItemStack[this.getSizeInventory()];

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
            byte b0 = nbttagcompound1.getByte("Slot");

            if (b0 >= 0 && b0 < this.slots.length)
            {
                this.slots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
            }
        }

        this.burnTime = compound.getShort("BurnTime");
        this.cookTime = compound.getShort("CookTime");
        this.cookTime = compound.getShort("CookTimeTotal");
        this.currentItemBurnTime = getItemBurnTime(this.slots[1]);

        if (compound.hasKey("CustomName", )
        {
            this.furnaceCustomName = compound.getString("CustomName");
        }
    }

public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
    {
        return new ContainerGrinder(playerInventory, this);
    }



public void writeToNBT(NBTTagCompound compound)
    {
        super.writeToNBT(compound);
        compound.setShort("BurnTime", (short)this.burnTime);
        compound.setShort("CookTime", (short)this.cookTime);
        compound.setShort("CookTimeTotal", (short)this.cookTime);
        NBTTagList nbttaglist = new NBTTagList();

        for (int i = 0; i < this.slots.length; ++i)
        {
            if (this.slots[i] != null)
            {
                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                nbttagcompound1.setByte("Slot", (byte)i);
                this.slots[i].writeToNBT(nbttagcompound1);
                nbttaglist.appendTag(nbttagcompound1);
            }
        }

        compound.setTag("Items", nbttaglist);

        if (this.hasCustomName())
        {
            compound.setString("CustomName", this.furnaceCustomName);
        }
    }

@SideOnly(Side.CLIENT)
    public int getBurnTimeRemainingScaled(int widthBurnBar)
    {
        if (this.currentItemBurnTime == 0)
        {
            this.currentItemBurnTime = 200;
        }

        return this.burnTime * widthBurnBar / this.currentItemBurnTime;
    }

public int getCookProgressScaled(int widthBurnBar)
    {
        return this.cookTime * widthBurnBar / 200;
    }

}

 

MainClass:

package com.expansion.main;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.IGuiHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

import com.expansion.MachinesRecpie.GrinderRecpie;
import com.expansion.achievements.achievementLists;
import com.expansion.blocks.BlockList;
import com.expansion.handler.GuiHandler;
import com.expansion.items.ItemList;
import com.expansion.recipes.CraftingManager;
import com.expansion.recipes.RecipesRemoval;
import com.expansion.recipes.SmeltingRegistry;
import com.expansion.tileEntities.TileEntityGrinder;
import com.expansion.worldGen.WorldRegster;
@Mod(modid = Main.modID, name = Main.Name,version= Main.Version)
public class Main {


public static final String modID = "expansion";
public static final String Name = "Expansion: Overhaul";
public static final String Version = "Alpha 0.0.5";
public static final String ClientProxy = "com.expansion.main.ClientProxy";
public static final String ServerProxy = "com.expansion.main.ServerProxy";

@SidedProxy(clientSide = Main.ClientProxy, serverSide = Main.ServerProxy)
public static ServerProxy proxy;

@Instance(modID)
public static Main instance;


@EventHandler
public void PreLoad(FMLPreInitializationEvent PreEvent){
	ItemList.MainRegistry();
	BlockList.MainRegistry();
	WorldRegster.MainRegistry();

}

@EventHandler
public void Load(FMLInitializationEvent Event){
	RecipesRemoval.RecpieRemover();	
	CraftingManager.registerCrafting();	
	SmeltingRegistry.RegisterSmelting();
	achievementLists.MainRegistry();
	NetworkRegistry.INSTANCE.registerGuiHandler(instance,new GuiHandler());
	GameRegistry.registerTileEntity(TileEntityGrinder.class, "TileEntityGrinder");


	proxy.RegisterRender();
}

@EventHandler
public void PostLoad(FMLPostInitializationEvent PostEvent){

}
}

Link to post
Share on other sites

I'm maybe not the best in Java  but what's is SlotFurnaceFuel?

Slot for coal..planks, charkcoal, wood tools etc

 

 

You are opening The gui on client side. Open The gui on Server side, The Server will Inform  The client about it

Changed from

if (!worldIn.isRemote)

To

if (worldIn.isRemote)

 

 

now it works...but furnace is not working ... :(

Thanks for answering.

 

Link to post
Share on other sites

but furnace is not working ... :(

We need more contect. What doesn't work? How do you want it to work? Have you tried debugging it yourself?

 

Always post updated code and more context if you want us to help.

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

Guest
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 Privacy Policy.