OSDN Git Service

c6e5d5048d44c64aa3761895edd6e470bffb5c42
[chemicraft/chemicraft.git] / common / chemicraft / container / ContainerElectrolysisTable.java
1 package 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 chemicraft.ChemiCraft;
8 import chemicraft.inventory.InventoryElectrolysisFuel;
9 import chemicraft.inventory.InventoryElectrolysisMaterial;
10 import chemicraft.inventory.InventoryElectrolysisResult;
11 import chemicraft.slot.SlotElectrolysisMaterial;
12 import chemicraft.slot.SlotElectrolysisResult;
13 import chemicraft.tileentity.TileEntityElectrolysisTable;
14
15 public class ContainerElectrolysisTable extends Container
16 {
17
18         private World worldObj;
19
20         private int posX;
21         private int posY;
22         private int posZ;
23
24         private TileEntityElectrolysisTable tileEntity;
25
26         private InventoryElectrolysisMaterial invm;
27         private InventoryElectrolysisResult invr;
28         private InventoryElectrolysisFuel invf;
29
30         public ContainerElectrolysisTable(EntityPlayer par1EntityPlayer, TileEntityElectrolysisTable par2) {
31                 super();
32                 this.worldObj = par2.worldObj;
33                 this.posX = par2.xCoord;
34                 this.posY = par2.yCoord;
35                 this.posZ = par2.zCoord;
36                 this.invm = (InventoryElectrolysisMaterial) this.tileEntity.getInvMaterial();
37                 this.invr = (InventoryElectrolysisResult) this.tileEntity.getInvResult();
38                 this.invf = (InventoryElectrolysisFuel) this.tileEntity.getInvFuel();
39
40                 this.addSlotToContainer(new SlotElectrolysisMaterial(invm, 0, 123, 34));
41                 for (int i = 0; i < 16; i++) {
42                         this.addSlotToContainer(new SlotElectrolysisResult(invr, i, 123, 34));
43                 }
44                 this.addSlotToContainer(new SlotElectrolysisResult(invf, 0, 123, 34));
45
46                 int var3;
47                 for (var3 = 0; var3 < 3; ++var3)
48                 {
49                         for (int var4 = 0; var4 < 9; ++var4)
50                         {
51                                 this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var4 + var3 * 9 + 9, 8 + var4 * 18, 85 + var3 * 18));
52                         }
53                 }
54
55                 for (var3 = 0; var3 < 9; ++var3)
56                 {
57                         this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var3, 8 + var3 * 18, 143));
58                 }
59
60         }
61
62         @Override
63         public boolean canInteractWith(EntityPlayer par1EntityPlayer)
64         {
65                 return true;
66                 //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;
67         }
68
69 }