OSDN Git Service

e79801ef6f2e365f53b11d6a2483e61503dadbd3
[chemicraft/chemicraft.git] / common / chemicraft / ContainerDecompositionTable.java
1 package chemicraft;
2
3 import cpw.mods.fml.common.network.PacketDispatcher;
4 import net.minecraft.src.Container;
5 import net.minecraft.src.EntityPlayer;
6 import net.minecraft.src.IInventory;
7 import net.minecraft.src.InventoryPlayer;
8 import net.minecraft.src.Item;
9 import net.minecraft.src.ItemStack;
10 import net.minecraft.src.Slot;
11 import net.minecraft.src.World;
12
13 public class ContainerDecompositionTable extends Container {
14
15         /**
16          * Worldのインスタンス
17          */
18         private World worldObj;
19
20
21         /**
22          * BlockのX, Y, Z座標
23          */
24         private int posX;
25         private int posY;
26         private int posZ;
27
28
29         /**
30          * the TileEntity.
31          */
32         private TileEntityDecompositionTable tileEntity;
33
34
35
36         public ContainerDecompositionTable(EntityPlayer par1EntityPlayer, TileEntityDecompositionTable par2)
37         {
38                 super();
39                 this.worldObj = par2.worldObj;
40                 this.posX = par2.xCoord;
41                 this.posY = par2.yCoord;
42                 this.posZ = par2.zCoord;
43                 this.tileEntity = par2;
44                 //GenerateInventory
45                 this.generateSlots("Decomposition", par2.getInventorys());
46                 //GeneratePlayerInventory
47                 int var3;
48
49                 for (var3 = 0; var3 < 3; ++var3)
50                 {
51                         for (int var4 = 0; var4 < 9; ++var4)
52                         {
53                                 this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var4 + var3 * 9 + 9, 8 + var4 * 18, 85 + var3 * 18));
54                         }
55                 }
56
57                 for (var3 = 0; var3 < 9; ++var3)
58                 {
59                         this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var3, 8 + var3 * 18, 143));
60                 }
61         }
62
63
64
65         @Override
66         public void onCraftMatrixChanged(IInventory par1IInventory){}
67
68
69
70         @Override
71         public void onCraftGuiClosed(EntityPlayer par1EntityPlayer){
72                 super.onCraftGuiClosed(par1EntityPlayer);
73         }
74
75
76
77         @Override
78         public boolean canInteractWith(EntityPlayer par1EntityPlayer){
79                 return this.worldObj.getBlockId(this.posX, this.posY, this.posZ) != ChemiCraft.instance.decompositionTableID ? false : par1EntityPlayer.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D;
80         }
81
82
83
84         @Override
85         public ItemStack transferStackInSlot(int par1){
86                 return null;
87         }
88
89
90
91         private void generateSlots(String activeTabs, IInventory[] inventorys){
92                 int count = 0;
93                 for(int i = 0;i < 4;i++){
94                         for(int j = 0;j < 4;j++){
95                                 this.addSlotToContainer(new SlotDecompositionResult(inventorys[0], count, 90 + 18 * j, 8 + 18 * i));
96                                 count++;
97                         }
98                 }
99                 this.addSlotToContainer(new Slot(inventorys[0], count, 28, 30));
100         }
101
102 }