OSDN Git Service

493692d0857b78f6569d5c6f54e8f1ccfbc9a06f
[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.SlotElectrolysisFuel;
12 import pcc.chemicraft.slot.SlotElectrolysisMaterial;
13 import pcc.chemicraft.slot.SlotElectrolysisResult;
14 import pcc.chemicraft.slot.SlotPyrolysisTableResult;
15 import pcc.chemicraft.tileentity.TileEntityElectrolysisTable;
16
17
18 public class ContainerElectrolysisTable extends Container {
19
20         private World worldObj;
21
22         private int posX;
23         private int posY;
24         private int posZ;
25
26         private TileEntityElectrolysisTable tileentity;
27
28         private InventoryElectrolysisMaterial invm;
29         private InventoryElectrolysisResult invr;
30         private InventoryElectrolysisFuel invf;
31
32         public ContainerElectrolysisTable(EntityPlayer par1EntityPlayer, TileEntityElectrolysisTable par2) {
33                 super();
34                 this.tileentity = par2;
35                 this.worldObj = par2.worldObj;
36                 this.posX = par2.xCoord;
37                 this.posY = par2.yCoord;
38                 this.posZ = par2.zCoord;
39                 this.invm = par2.getInvMaterial();
40                 this.invr = par2.getInvResult();
41                 this.invf = par2.getInvFuel();
42                 this.invm.setEventHandler(this);
43                 this.invr.setEventHandler(this);
44                 this.invf.setEventHandler(this);
45
46                 for (int i = 0; i < 4; i++) {
47                         for (int j = 0; j < 4; j++) {
48                                 this.addSlotToContainer(new SlotElectrolysisResult(this.tileentity.getInvResult(), i*4 + j, 88+i*18, 17+j*18));
49                         }
50                 }
51                 this.addSlotToContainer(new SlotElectrolysisMaterial(this.tileentity.getInvMaterial(), 0, 27, 20));
52                 this.addSlotToContainer(new SlotElectrolysisFuel(this.tileentity.getInvFuel(), 0, 27, 63));
53
54                 int var3;
55                 for (var3 = 0; var3 < 3; ++var3)
56                 {
57                         for (int var4 = 0; var4 < 9; ++var4)
58                         {
59                                 this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var4 + var3 * 9 + 9, 8 + var4 * 18, 121 + var3 * 18));
60                         }
61                 }
62
63                 for (var3 = 0; var3 < 9; ++var3)
64                 {
65                         this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var3, 8 + var3 * 18, 179));
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 }