OSDN Git Service

修正・変更
[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.slot.SlotElectrolysisMaterial;
9 import chemicraft.slot.SlotElectrolysisResult;
10 import chemicraft.tileentity.TileEntityElectrolysisTable;
11
12 public class ContainerElectrolysisTable extends Container
13 {
14
15         private World worldObj;
16
17         private int posX;
18         private int posY;
19         private int posZ;
20
21         private TileEntityElectrolysisTable tileentity;
22
23         public ContainerElectrolysisTable(EntityPlayer par1EntityPlayer, TileEntityElectrolysisTable par2) {
24                 super();
25                 this.worldObj = par2.worldObj;
26                 this.posX = par2.xCoord;
27                 this.posY = par2.yCoord;
28                 this.posZ = par2.zCoord;
29
30                 this.addSlotToContainer(new SlotElectrolysisMaterial(this.tileentity.getInvMaterial(), 0, 123, 34));
31                 for (int i = 0; i < 16; i++) {
32                         this.addSlotToContainer(new SlotElectrolysisResult(this.tileentity.getInvResult(), i, 123, 34));
33                 }
34                 this.addSlotToContainer(new SlotElectrolysisResult(this.tileentity.getInvFuel(), 0, 123, 34));
35
36                 int var3;
37                 for (var3 = 0; var3 < 3; ++var3)
38                 {
39                         for (int var4 = 0; var4 < 9; ++var4)
40                         {
41                                 this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var4 + var3 * 9 + 9, 8 + var4 * 18, 85 + var3 * 18));
42                         }
43                 }
44
45                 for (var3 = 0; var3 < 9; ++var3)
46                 {
47                         this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var3, 8 + var3 * 18, 143));
48                 }
49
50         }
51
52         @Override
53         public boolean canInteractWith(EntityPlayer par1EntityPlayer)
54         {
55                 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;
56         }
57
58 }