OSDN Git Service

38d6911d140c9d9a1d1d4881217651ce59feb5f7
[chemicraft/chemicraft.git] / common / pcc / chemicraft / container / ContainerPyrolysisTable.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.slot.SlotPyrolysisTableFuel;
9 import pcc.chemicraft.slot.SlotPyrolysisTableMaterial;
10 import pcc.chemicraft.slot.SlotPyrolysisTableResult;
11 import pcc.chemicraft.tileentity.TileEntityPyrolysisTable;
12
13
14 public class ContainerPyrolysisTable extends Container {
15
16         private World worldObj;
17
18         private int posX;
19         private int posY;
20         private int posZ;
21
22         private TileEntityPyrolysisTable tileentity;
23
24         public ContainerPyrolysisTable(EntityPlayer par1EntityPlayer, TileEntityPyrolysisTable par2){
25                 super();
26                 this.tileentity = par2;
27                 this.worldObj = par2.worldObj;
28                 this.posX = par2.xCoord;
29                 this.posY = par2.yCoord;
30                 this.posZ = par2.zCoord;
31
32                 for (int i = 0; i < 4; i++) {
33                         for (int j = 0; j < 4; j++) {
34                                 this.addSlotToContainer(new SlotPyrolysisTableResult(this.tileentity.getInvResult(), i*4 + j, 88+i*18, 17+j*18));
35                         }
36                 }
37                 this.addSlotToContainer(new SlotPyrolysisTableMaterial(this.tileentity.getInvMaterial(), 0, 27, 20));
38                 this.addSlotToContainer(new SlotPyrolysisTableFuel(this.tileentity.getInvFuel(), 0, 27, 63));
39
40                 int var3;
41                 for (var3 = 0; var3 < 3; ++var3)
42                 {
43                         for (int var4 = 0; var4 < 9; ++var4)
44                         {
45                                 this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var4 + var3 * 9 + 9, 8 + var4 * 18, 121 + var3 * 18));
46                         }
47                 }
48
49                 for (var3 = 0; var3 < 9; ++var3)
50                 {
51                         this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var3, 8 + var3 * 18, 179));
52                 }
53         }
54
55         @Override
56         public boolean canInteractWith(EntityPlayer par1EntityPlayer) {
57                 return this.worldObj.getBlockId(this.posX, this.posY, this.posZ) != ChemiCraft.instance.pyrolysisTableID ? false : par1EntityPlayer.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D;
58         }
59
60 }