OSDN Git Service

同期バグ修正
[chemicraft/chemicraft.git] / common / chemicraft / inventory / InventoryChemicalCombinationTableResult.java
1 package chemicraft.inventory;
2
3 import net.minecraft.src.Container;
4 import net.minecraft.src.EntityPlayer;
5 import net.minecraft.src.IInventory;
6 import net.minecraft.src.ItemStack;
7
8 public class InventoryChemicalCombinationTableResult implements IInventory {
9
10         private ItemStack[] inventory = new ItemStack[15];
11         private Container eventHandler;
12
13         public void setEventHandler(Container par1){
14                 this.eventHandler = par1;
15         }
16
17         @Override
18         public int getSizeInventory() {
19                 return this.inventory.length;
20         }
21
22         @Override
23         public ItemStack getStackInSlot(int var1) {
24                 return this.inventory[var1];
25         }
26
27         @Override
28         public ItemStack decrStackSize(int var1, int var2) {
29                 if (this.inventory[var1] != null)
30                 {
31                         ItemStack var3;
32
33                         if (this.inventory[var1].stackSize <= var2)
34                         {
35                                 var3 = this.inventory[var1];
36                                 this.inventory[var1] = null;
37                                 this.onInventoryChanged();
38                                 return var3;
39                         }
40                         else
41                         {
42                                 var3 = this.inventory[var1].splitStack(var2);
43
44                                 if (this.inventory[var1].stackSize == 0)
45                                 {
46                                         this.inventory[var1] = null;
47                                 }
48
49                                 this.onInventoryChanged();
50                                 return var3;
51                         }
52                 }
53                 else
54                 {
55                         return null;
56                 }
57         }
58
59         @Override
60         public ItemStack getStackInSlotOnClosing(int var1) {
61                 if (this.inventory[var1] != null)
62                 {
63                         ItemStack var2 = this.inventory[var1];
64                         this.inventory[var1] = null;
65                         return var2;
66                 }
67                 else
68                 {
69                         return null;
70                 }
71         }
72
73         @Override
74         public void setInventorySlotContents(int var1, ItemStack var2) {
75                 this.inventory[var1] = var2;
76
77                 if (var2 != null && var2.stackSize > this.getInventoryStackLimit())
78                 {
79                         var2.stackSize = this.getInventoryStackLimit();
80                 }
81
82                 this.onInventoryChanged();
83         }
84
85         @Override
86         public String getInvName() {
87                 return "ChemicalCombinationTableResult";
88         }
89
90         @Override
91         public int getInventoryStackLimit() {
92                 return 64;
93         }
94
95         @Override
96         public void onInventoryChanged() {
97                 if(this.eventHandler != null) this.eventHandler.onCraftMatrixChanged(this);
98         }
99
100         @Override
101         public boolean isUseableByPlayer(EntityPlayer var1) {
102                 return true;
103         }
104
105         @Override
106         public void openChest() {
107         }
108
109         @Override
110         public void closeChest() {
111         }
112
113
114 }