Jump to content

1.7.10 Need Help with custom furnace - Fuel & Gui (Files Updated)


Alpha_43

Recommended Posts

So I got problem with my Fire Grill (custom furnace).

 

1st of all, I had a look at the codes of the furnace

(basically copied the codes and changed what had to be changed)

but now, i want my Grill to cook items when there is fire (Blocks.fire) under it.

so just like a normal fire grill. (but i tried to convert getItemBurnTime to GetBurnTime)

(it's kind of near the end)

 

 

package alpha.enhancedSurvival.Models;

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.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import alpha.enhancedSurvival.EnhancedSurvival;
import alpha.enhancedSurvival.GrillRecipes;
import alpha.enhancedSurvival.GUI.ModGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class TileEntityFireGrillEntity extends TileEntity implements ISidedInventory
{
    private static final int[] slotsTop = new int[] {0};
    private static final int[] slotsSides = new int[] {0};
    /** The ItemStacks that hold the items currently being used */
    private ItemStack[] grillItemStacks = new ItemStack[2];
    /** The number of ticks that the grill will keep burning */
    public int grillBurnTime;
    /** The number of ticks that the grill is burning for */
    public int currentBurnTime;
    /** The number of ticks that the current item has been cooking for */
    public int grillCookTime;
    private String hasCustomName;
    
    public TileEntityFireGrillEntity te;

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

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

    /**
     * Removes from an inventory slot up to a specified number of items and returns them in a
     * new stack.
     */
    public ItemStack decrStackSize(int slot, int ItemQty)
    {
        if (this.grillItemStacks[slot] != null)
        {
            ItemStack itemstack;

            if (this.grillItemStacks[slot].stackSize <= ItemQty)
            {
                itemstack = this.grillItemStacks[slot];
                this.grillItemStacks[slot] = null;
                return itemstack;
            }
            else
            {
                itemstack = this.grillItemStacks[slot].splitStack(ItemQty);

                if (this.grillItemStacks[slot].stackSize == 0)
                {
                    this.grillItemStacks[slot] = null;
                }

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

    /**
     * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
     */
    public ItemStack getStackInSlotOnClosing(int slot)
    {
        if (this.grillItemStacks[slot] != null)
        {
            ItemStack itemstack = this.grillItemStacks[slot];
            this.grillItemStacks[slot] = null;
            return itemstack;
        }
        else
        {
            return null;
        }
    }

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

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

    /**
     * Returns the name of the inventory
     */
    public String getInventoryName()
    {
        return this.hasCustomInventoryName() ? this.hasCustomName : "container.grill";
    }

    /**
     * Returns if the inventory is named
     */
    public boolean hasCustomInventoryName()
    {
        return this.hasCustomName != null && this.hasCustomName.length() > 0;
    }

    public void setCustomName(String customName)
    {
        this.hasCustomName = customName;
    }

    public void readFromNBT(NBTTagCompound compund)
    {
        super.readFromNBT(compund);
        NBTTagList nbttaglist = compund.getTagList("Items", 10);
        this.grillItemStacks = 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.grillItemStacks.length)
            {
                this.grillItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
            }
        }

        this.grillBurnTime = compund.getShort("BurnTime");
        this.grillCookTime = compund.getShort("CookTime");
        this.currentBurnTime = getBurnTime(null);

        if (compund.hasKey("CustomName", )
        {
            this.hasCustomName = compund.getString("CustomName");
        }
    }

    public void writeToNBT(NBTTagCompound compund)
    {
        super.writeToNBT(compund);
        compund.setShort("BurnTime", (short)this.grillBurnTime);
        compund.setShort("CookTime", (short)this.grillCookTime);
        NBTTagList nbttaglist = new NBTTagList();

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

        compund.setTag("Items", nbttaglist);

        if (this.hasCustomInventoryName())
        {
            compund.setString("CustomName", this.hasCustomName);
        }
    }

    
    public int getInventoryStackLimit()
    {
        return 64;
    }

    
    @SideOnly(Side.CLIENT)
    public int getCookProgressScaled(int timeBeforeCooked)
    {
        return this.grillCookTime * timeBeforeCooked / 200;
    }

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

        return this.grillBurnTime * burnTimeLeft / this.currentBurnTime;
    }

    /**
     * Furnace isBurning
     */
    public boolean isBurning()
    {
        return this.grillBurnTime > 0;
    }

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

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

        if (!this.worldObj.isRemote)
        {
            if (this.grillBurnTime != 0 || this.grillItemStacks[1] != null && this.grillItemStacks[0] != null)
            {
                if (this.grillBurnTime == 0 && this.canSmelt())
                {
                    this.currentBurnTime = this.grillBurnTime = getBurnTime(null);

                    if (this.grillBurnTime > 0)
                    {
                        flag1 = true;

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

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

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

                    if (this.grillCookTime == 200)
                    {
                        this.grillCookTime = 0;
                        this.smeltItem();
                        flag1 = true;
                    }
                }
                else
                {
                    this.grillCookTime = 0;
                }
            }
        }

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

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

    /**
     * Turn one item from the grill source stack into the appropriate smelted item in the grill result stack
     */
    public void smeltItem()
    {
        if (this.canSmelt())
        {
            ItemStack itemstack = GrillRecipes.smelting().getSmeltingResult(this.grillItemStacks[0]);

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

            --this.grillItemStacks[0].stackSize;

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

    
    public static int getBurnTime(ItemStack itemstack)
    {
    	
        return 200;
    }


    /**
     * Do not make give this method the name canInteractWith because it crashes with Container
     */
    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;
    }

    public void openInventory() {}

    public void closeInventory() {}

    
    public int[] getAccessibleSlotsFromSide(int slot)
    {
        return slot == 1 ? slotsTop : slotsSides;
    }

    
    public boolean canInsertItem(int slot, ItemStack item, int side)
    {
        return this.isItemValidForSlot(slot, item);
    }
    

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

private boolean itemstack(boolean b) {
	return false;
}

private boolean isItemSmeltable() 
{
	return getBurnTime(null) > 0;
}

@Override
public boolean canExtractItem(int slot, ItemStack item, int side) {
	return false;
}

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int l, float m, float n, float o) {
    if (world.isRemote) {
        player.openGui(EnhancedSurvival.instance, ModGuiHandler.GuiTileEntity, world, x, y, z);
    }
    return true;
}

 

 

2nd of all, I have problem with the Gui.

it's impossible to pick up the items directly, while in the gui,

Items shows up where they are, unless you try to take them. They are ofsetted by 1 up and 2 right, So if i click down 1 & left 2, i'm able to pick the item.

hope someone can help me with this one

 

there is the gui (think there is no problem, but feel free to check)

 

package alpha.enhancedSurvival.GUI;

import org.lwjgl.opengl.GL11;

import alpha.enhancedSurvival.Inventory.ContainerGrill;
import alpha.enhancedSurvival.Models.TileEntityFireGrillEntity;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

public class GuiFireGrill extends GuiContainer {

private TileEntityFireGrillEntity te;

public GuiFireGrill(IInventory playerInv, TileEntityFireGrillEntity tileGrill) {
	super(new ContainerGrill((InventoryPlayer) playerInv, tileGrill));
	this.te = tileGrill;

	this.xSize = 176;
	this.ySize = 166;
}

@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    this.mc.getTextureManager().bindTexture(new ResourceLocation("EnhancedSurvival:textures/gui/GrillGui.png"));
    this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
    if (this.te.isBurning())
        {
            int i1 = this.te.getBurnTimeRemainingScaled(13);
            this.drawTexturedModalRect(this.guiLeft + 56, this.guiTop + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1);
            i1 = this.te.getCookProgressScaled(24);
            this.drawTexturedModalRect(this.guiLeft + 79, this.guiTop + 34, 176, 14, i1 + 1, 16);
        }
}

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
	String s = this.te.hasCustomInventoryName() ? this.te.getInventoryName() : I18n.format(this.te.getInventoryName(), new Object[0]);
    this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
    this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
}

}

 

this the container

 

package alpha.enhancedSurvival.Inventory;

import alpha.enhancedSurvival.GrillRecipes;
import alpha.enhancedSurvival.Models.TileEntityFireGrillEntity;
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.Slot;
import net.minecraft.inventory.SlotFurnace;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.tileentity.TileEntityFurnace;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ContainerGrill extends Container
{
    private TileEntityFireGrillEntity tileGrill;
    private int lastCookTime;
    private int lastBurnTime;
    private int lastItemBurnTime;

    public ContainerGrill(InventoryPlayer playerInv, TileEntityFireGrillEntity tileGrill)
    {
        this.tileGrill = tileGrill;
        this.addSlotToContainer(new Slot(tileGrill, 0, 57, 36));
        this.addSlotToContainer(new SlotGrill(playerInv.player, tileGrill, 1, 111, 36));
        int i;

        for (i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 9; ++j)
            {
                this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
            }
        }

        for (i = 0; i < 9; ++i)
        {
            this.addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
        }
    }

    public void addCraftingToCrafters(ICrafting crafter)
    {
        super.addCraftingToCrafters(crafter);
        crafter.sendProgressBarUpdate(this, 0, this.tileGrill.grillCookTime);
        crafter.sendProgressBarUpdate(this, 1, this.tileGrill.grillBurnTime);
        crafter.sendProgressBarUpdate(this, 2, this.tileGrill.currentBurnTime);
    }

    /**
     * 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.lastCookTime != this.tileGrill.grillCookTime)
            {
                icrafting.sendProgressBarUpdate(this, 0, this.tileGrill.grillCookTime);
            }

            if (this.lastBurnTime != this.tileGrill.grillBurnTime)
            {
                icrafting.sendProgressBarUpdate(this, 1, this.tileGrill.grillBurnTime);
            }

            if (this.lastItemBurnTime != this.tileGrill.currentBurnTime)
            {
                icrafting.sendProgressBarUpdate(this, 2, this.tileGrill.currentBurnTime);
            }
        }

        this.lastCookTime = this.tileGrill.grillCookTime;
        this.lastBurnTime = this.tileGrill.grillBurnTime;
        this.lastItemBurnTime = this.tileGrill.currentBurnTime;
    }

    @SideOnly(Side.CLIENT)
    public void updateProgressBar(int listener, int packet)
    {
        if (listener == 0)
        {
            this.tileGrill.grillCookTime = packet;
        }

        if (listener == 1)
        {
            this.tileGrill.grillBurnTime = packet;
        }

        if (listener == 2)
        {
            this.tileGrill.currentBurnTime = packet;
        }
    }

    @Override
    public boolean canInteractWith(EntityPlayer player)
    {
        return this.tileGrill.isUseableByPlayer(player);
    }

    /**
     * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
     */
    @Override
    public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
    {
        Slot slot = getSlot(slotID);
        ItemStack itemstack = slot.getStack();
        ItemStack result = itemstack.copy();

        if (slot != null && slot.getHasStack())
        {
            

            if (slotID == 1)
            {
                if (!this.mergeItemStack(itemstack, 2, 37, true))
                {
                    return null;
                }

                slot.onSlotChange(itemstack, result);
            }
            else if (slotID != 0)
            {
                if (GrillRecipes.smelting().getSmeltingResult(itemstack) != null)
                {
                    if (!this.mergeItemStack(itemstack, 0, 0, false))
                    {
                        return null;
                    }
                }
                else if (slotID >= 2 && slotID < 29)
                {
                    if (!this.mergeItemStack(itemstack, 29, 37, false))
                    {
                        return null;
                    }
                }
                else if (slotID >= 29 && slotID < 38 && !this.mergeItemStack(itemstack, 2, 29, false))
                {
                    return null;
                }
            }
            else if (!this.mergeItemStack(itemstack, 2, 37, false))
            {
                return null;
            }

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

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

            slot.onPickupFromSlot(player, itemstack);
        }

        return result;
    }
}

 

 

let me know if some thing would need to be removed too for everything to work.

everything else is good.

If you need other class file, just ask

 

ps: I know what must think, "why don't you code it for 1.8?" Because I want it for 1.7.10, i began coding for it. if I finish it then maybe I will update it to 1.8!

 

Link to comment
Share on other sites

You need to check the block under the grill.

 

Also, you have a TON of copy-pasted shit you absolutely don't need.

Like,

private static final String __OBFID = "CL_00000357";

which just shows everyone else that all you did was copy-paste the entire furnace class.

 

You also didn't use the [ code] tag when pasting your code.  Now it's borderline unreadable because there was an

[i]

in it.

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

1st of all, you didn't read it all, because i said I copied the code of the furnace.

2, I tried everything with that GetBurnTime() that only accected ItemStack

(I need "World, x ,y ,z" so what i try to do works)

 

Oh and in case you didn't notice, i'm new HERE, didn't knew about [ code]

but thanks now i know.

 

so if you care having another look.

 

Link to comment
Share on other sites

You first have to make sure that you understand the code. Do you? To make sure, refactor your code and post the updated 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

Ok, deobfuscated the codes.

should have done it before.

what's true is that its easier to understand now

(mean it takes a second to understand than a minute or two)

 

made me see some overlooked stupid errors. which doesn't really change anything to my problem

Link to comment
Share on other sites

Ok So right now, because it would be hard to see if the fuel situation work

I need help with the Gui problem

 

briefing:

the items are sync 8 block too soon

so the items appear 1 slot up & 2 slot right,

but i can take them if i click 1 slot down & 2 slot left

 

there's an image to help you see it: http://imgur.com/JZRjzue

and when i try to take it from where it appears, it get back there after i pick it up.

Link to comment
Share on other sites

So i've been playing with the order of "generation" of the player & grill inventory.

managed by this, to get the slots of my grill and all the 3x9 player inventory, working,

but the player hotbar inventory won't let me do anything

 

there's the updated Container file from my manipulations

 

package alpha.enhancedSurvival.Inventory;

import alpha.enhancedSurvival.GrillRecipes;
import alpha.enhancedSurvival.Models.TileEntityFireGrillEntity;
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.Slot;
import net.minecraft.inventory.SlotFurnace;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.tileentity.TileEntityFurnace;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ContainerGrill extends Container
{
    private TileEntityFireGrillEntity tileGrill;
    private int lastCookTime;
    private int lastBurnTime;
    private int lastItemBurnTime;

    public ContainerGrill(InventoryPlayer playerInv, TileEntityFireGrillEntity tileGrill)
    {
        this.tileGrill = tileGrill;
        int i;

        for (i = 0; i < 9; ++i)
        {
            this.addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
        }

        for (i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 9; ++j)
            {
                this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
            }
        }
        
        this.addSlotToContainer(new Slot(tileGrill, 0, 57, 36));
        this.addSlotToContainer(new SlotGrill(playerInv.player, tileGrill, 1, 111, 36));
    }

    public void addCraftingToCrafters(ICrafting crafter)
    {
        super.addCraftingToCrafters(crafter);
        crafter.sendProgressBarUpdate(this, 0, this.tileGrill.grillCookTime);
        crafter.sendProgressBarUpdate(this, 1, this.tileGrill.grillBurnTime);
        crafter.sendProgressBarUpdate(this, 2, this.tileGrill.currentBurnTime);
    }

    /**
     * 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.lastCookTime != this.tileGrill.grillCookTime)
            {
                icrafting.sendProgressBarUpdate(this, 0, this.tileGrill.grillCookTime);
            }

            if (this.lastBurnTime != this.tileGrill.grillBurnTime)
            {
                icrafting.sendProgressBarUpdate(this, 1, this.tileGrill.grillBurnTime);
            }

            if (this.lastItemBurnTime != this.tileGrill.currentBurnTime)
            {
                icrafting.sendProgressBarUpdate(this, 2, this.tileGrill.currentBurnTime);
            }
        }

        this.lastCookTime = this.tileGrill.grillCookTime;
        this.lastBurnTime = this.tileGrill.grillBurnTime;
        this.lastItemBurnTime = this.tileGrill.currentBurnTime;
    }

    @SideOnly(Side.CLIENT)
    public void updateProgressBar(int listener, int packet)
    {
        if (listener == 0)
        {
            this.tileGrill.grillCookTime = packet;
        }

        if (listener == 1)
        {
            this.tileGrill.grillBurnTime = packet;
        }

        if (listener == 2)
        {
            this.tileGrill.currentBurnTime = packet;
        }
    }

    @Override
    public boolean canInteractWith(EntityPlayer player)
    {
        return this.tileGrill.isUseableByPlayer(player);
    }

    /**
     * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
     */
    @Override
    public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
    {
        Slot slot = getSlot(slotID);
        ItemStack itemstack = slot.getStack();
        ItemStack result = itemstack.copy();

        if (slot != null && slot.getHasStack())
        {
            

            if (slotID == 1)
            {
                if (!this.mergeItemStack(itemstack, 2, 37, true))
                {
                    return null;
                }

                slot.onSlotChange(itemstack, result);
            }
            else if (slotID != 0)
            {
                if (GrillRecipes.smelting().getSmeltingResult(itemstack) != null)
                {
                    if (!this.mergeItemStack(itemstack, 0, 0, false))
                    {
                        return null;
                    }
                }
                else if (slotID >= 2 && slotID < 29)
                {
                    if (!this.mergeItemStack(itemstack, 29, 37, false))
                    {
                        return null;
                    }
                }
                else if (slotID >= 29 && slotID < 38 && !this.mergeItemStack(itemstack, 2, 29, false))
                {
                    return null;
                }
            }
            else if (!this.mergeItemStack(itemstack, 2, 37, false))
            {
                return null;
            }

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

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

            slot.onPickupFromSlot(player, itemstack);
        }

        return result;
    }
}

 

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.