ContainerFurnace .java

net.minecraft.inventory.ContainerFurnace (class): members: currentItemBurnTime, furnaceBurnTime, totalCookTime, tileFurnace, cookTime, updateProgressBar.

net.minecraft.inventoryclass167 linescommonextends Container5.1 KB

API Surface (5)

void onCraftGuiOpened(ICrafting listener)
void detectAndSendChanges()
void updateProgressBar(int id, int data)
boolean canInteractWith(EntityPlayer playerIn)
ItemStack transferStackInSlot(EntityPlayer playerIn, int index)

Fields & Constants (5)

tileFurnace
cookTime
totalCookTime
furnaceBurnTime
currentItemBurnTime

Full Source

ContainerFurnace.java167 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.inventory;
2
3
import net.minecraft.entity.player.EntityPlayer;
4
import net.minecraft.entity.player.InventoryPlayer;
5
import net.minecraft.item.ItemStack;
6
import net.minecraft.item.crafting.FurnaceRecipes;
7
import net.minecraft.tileentity.TileEntityFurnace;
8
9
public class ContainerFurnace extends Container
10
{
11
    private final IInventory tileFurnace;
12
    private int cookTime;
13
    private int totalCookTime;
14
    private int furnaceBurnTime;
15
    private int currentItemBurnTime;
16
17
    public ContainerFurnace(InventoryPlayer playerInventory, IInventory furnaceInventory)
18
    {
19
        this.tileFurnace = furnaceInventory;
20
        this.addSlotToContainer(new Slot(furnaceInventory, 0, 56, 17));
21
        this.addSlotToContainer(new SlotFurnaceFuel(furnaceInventory, 1, 56, 53));
22
        this.addSlotToContainer(new SlotFurnaceOutput(playerInventory.player, furnaceInventory, 2, 116, 35));
23
24
        for (int i = 0; i < 3; ++i)
25
        {
26
            for (int j = 0; j < 9; ++j)
27
            {
28
                this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
29
            }
30
        }
31
32
        for (int k = 0; k < 9; ++k)
33
        {
34
            this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
35
        }
36
    }
37
38
    public void onCraftGuiOpened(ICrafting listener)
39
    {
40
        super.onCraftGuiOpened(listener);
41
        listener.sendAllWindowProperties(this, this.tileFurnace);
42
    }
43
44
    /**
45
     * Looks for changes made in the container, sends them to every listener.
46
     */
47
    public void detectAndSendChanges()
48
    {
49
        super.detectAndSendChanges();
50
51
        for (int i = 0; i < this.crafters.size(); ++i)
52
        {
53
            ICrafting icrafting = (ICrafting)this.crafters.get(i);
54
55
            if (this.cookTime != this.tileFurnace.getField(2))
56
            {
57
                icrafting.sendProgressBarUpdate(this, 2, this.tileFurnace.getField(2));
58
            }
59
60
            if (this.furnaceBurnTime != this.tileFurnace.getField(0))
61
            {
62
                icrafting.sendProgressBarUpdate(this, 0, this.tileFurnace.getField(0));
63
            }
64
65
            if (this.currentItemBurnTime != this.tileFurnace.getField(1))
66
            {
67
                icrafting.sendProgressBarUpdate(this, 1, this.tileFurnace.getField(1));
68
            }
69
70
            if (this.totalCookTime != this.tileFurnace.getField(3))
71
            {
72
                icrafting.sendProgressBarUpdate(this, 3, this.tileFurnace.getField(3));
73
            }
74
        }
75
76
        this.cookTime = this.tileFurnace.getField(2);
77
        this.furnaceBurnTime = this.tileFurnace.getField(0);
78
        this.currentItemBurnTime = this.tileFurnace.getField(1);
79
        this.totalCookTime = this.tileFurnace.getField(3);
80
    }
81
82
    public void updateProgressBar(int id, int data)
83
    {
84
        this.tileFurnace.setField(id, data);
85
    }
86
87
    public boolean canInteractWith(EntityPlayer playerIn)
88
    {
89
        return this.tileFurnace.isUseableByPlayer(playerIn);
90
    }
91
92
    /**
93
     * Take a stack from the specified inventory slot.
94
     */
95
    public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
96
    {
97
        ItemStack itemstack = null;
98
        Slot slot = (Slot)this.inventorySlots.get(index);
99
100
        if (slot != null && slot.getHasStack())
101
        {
102
            ItemStack itemstack1 = slot.getStack();
103
            itemstack = itemstack1.copy();
104
105
            if (index == 2)
106
            {
107
                if (!this.mergeItemStack(itemstack1, 3, 39, true))
108
                {
109
                    return null;
110
                }
111
112
                slot.onSlotChange(itemstack1, itemstack);
113
            }
114
            else if (index != 1 && index != 0)
115
            {
116
                if (FurnaceRecipes.instance().getSmeltingResult(itemstack1) != null)
117
                {
118
                    if (!this.mergeItemStack(itemstack1, 0, 1, false))
119
                    {
120
                        return null;
121
                    }
122
                }
123
                else if (TileEntityFurnace.isItemFuel(itemstack1))
124
                {
125
                    if (!this.mergeItemStack(itemstack1, 1, 2, false))
126
                    {
127
                        return null;
128
                    }
129
                }
130
                else if (index >= 3 && index < 30)
131
                {
132
                    if (!this.mergeItemStack(itemstack1, 30, 39, false))
133
                    {
134
                        return null;
135
                    }
136
                }
137
                else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
138
                {
139
                    return null;
140
                }
141
            }
142
            else if (!this.mergeItemStack(itemstack1, 3, 39, false))
143
            {
144
                return null;
145
            }
146
147
            if (itemstack1.stackSize == 0)
148
            {
149
                slot.putStack((ItemStack)null);
150
            }
151
            else
152
            {
153
                slot.onSlotChanged();
154
            }
155
156
            if (itemstack1.stackSize == itemstack.stackSize)
157
            {
158
                return null;
159
            }
160
161
            slot.onPickupFromSlot(playerIn, itemstack1);
162
        }
163
164
        return itemstack;
165
    }
166
}
167

Deobfuscated MCP 1.8.9 source of ContainerFurnace from Marcelektro/MavenMCP-1.8.9 (net/minecraft/inventory/ContainerFurnace.java), stored verbatim.