OSDN Git Service

Merge branch 'master' of https://scm.sourceforge.jp/gitroot/chemicraft/chemicraft
[chemicraft/chemicraft.git] / common / pcc / chemicraft / container / ContainerElectrolysisTable.java
1 package pcc.chemicraft.container;
2
3 import net.minecraft.entity.player.EntityPlayer;
4 import net.minecraft.inventory.Container;
5 import net.minecraft.inventory.Slot;
6 import net.minecraft.world.World;
7 import pcc.chemicraft.ChemiCraft;
8 import pcc.chemicraft.inventory.InventoryElectrolysisFuel;
9 import pcc.chemicraft.inventory.InventoryElectrolysisMaterial;
10 import pcc.chemicraft.inventory.InventoryElectrolysisResult;
11 import pcc.chemicraft.slot.SlotPyrolysisTableFuel;
12 import pcc.chemicraft.slot.SlotPyrolysisTableMaterial;
13 import pcc.chemicraft.slot.SlotPyrolysisTableResult;
14 import pcc.chemicraft.tileentity.TileEntityElectrolysisTable;
15
16 public class ContainerElectrolysisTable extends Container
17 {
18
19         private World worldObj;
20
21         private int posX;
22         private int posY;
23         private int posZ;
24
25         private InventoryElectrolysisMaterial invm;
26         private InventoryElectrolysisResult invr;
27         private InventoryElectrolysisFuel invf;
28
29         private TileEntityElectrolysisTable tileentity;
30
31         public ContainerElectrolysisTable(EntityPlayer par1EntityPlayer, TileEntityElectrolysisTable par2) {
32                 super();
33                 this.tileentity = par2;
34                 this.worldObj = par2.worldObj;
35                 this.posX = par2.xCoord;
36                 this.posY = par2.yCoord;
37                 this.posZ = par2.zCoord;
38                 this.invm = par2.getInvMaterial();
39                 this.invr = par2.getInvResult();
40                 this.invf = par2.getInvFuel();
41                 this.invm.setEventHandler(this);
42                 this.invr.setEventHandler(this);
43                 this.invf.setEventHandler(this);
44
45                 for (int i = 0; i < 4; i++) {
46                         for (int j = 0; j < 4; j++) {
47                                 this.addSlotToContainer(new SlotPyrolysisTableResult(this.invr, i*4 + j, 88+i*18, 17+j*18));
48                         }
49                 }
50                 this.addSlotToContainer(new SlotPyrolysisTableMaterial(this.invm, 0, 27, 20));
51                 this.addSlotToContainer(new SlotPyrolysisTableFuel(this.invf, 0, 27, 63));
52
53                 int var3;
54                 for (var3 = 0; var3 < 3; ++var3)
55                 {
56                         for (int var4 = 0; var4 < 9; ++var4)
57                         {
58                                 this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var4 + var3 * 9 + 9, 8 + var4 * 18, 121 + var3 * 18));
59                         }
60                 }
61
62                 for (var3 = 0; var3 < 9; ++var3)
63                 {
64                         this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var3, 8 + var3 * 18, 179));
65                 }
66
67         }
68
69         @Override
70         public boolean canInteractWith(EntityPlayer par1EntityPlayer)
71         {
72                 return this.worldObj.getBlockId(this.posX, this.posY, this.posZ) != ChemiCraft.instance.electrolysisTableID ? false : par1EntityPlayer.getDistanceSq((double) this.posX + 0.5D, (double) this.posY + 0.5D, (double) this.posZ + 0.5D) <= 64.0D;
73         }
74
75 }