-
Notifications
You must be signed in to change notification settings - Fork 755
/
ToolStationBlock.java
223 lines (199 loc) · 6.93 KB
/
ToolStationBlock.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
package tconstruct.blocks;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mantle.blocks.abstracts.InventoryBlock;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.PartBuilderLogic;
import tconstruct.blocks.logic.PatternChestLogic;
import tconstruct.blocks.logic.StencilTableLogic;
import tconstruct.blocks.logic.ToolStationLogic;
import tconstruct.client.block.TableRender;
import tconstruct.common.TRepo;
import tconstruct.library.TConstructRegistry;
import tconstruct.util.config.PHConstruct;
public class ToolStationBlock extends InventoryBlock
{
public ToolStationBlock(Material material)
{
super(material);
this.func_149647_a(TConstructRegistry.blockTab);
this.func_149711_c(2f);
this.func_149672_a(Block.field_149766_f);
}
//Block.hasComparatorInputOverride and Block.getComparatorInputOverride
/* Rendering */
@Override
public String[] getTextureNames ()
{
String[] textureNames = { "toolstation_top", "toolstation_side", "toolstation_bottom", "partbuilder_oak_top", "partbuilder_oak_side", "partbuilder_oak_bottom", "partbuilder_spruce_top",
"partbuilder_spruce_side", "partbuilder_spruce_bottom", "partbuilder_birch_top", "partbuilder_birch_side", "partbuilder_birch_bottom", "partbuilder_jungle_top",
"partbuilder_jungle_side", "partbuilder_jungle_bottom", "patternchest_top", "patternchest_side", "patternchest_bottom", "stenciltable_oak_top", "stenciltable_oak_side",
"stenciltable_oak_bottom", "stenciltable_spruce_top", "stenciltable_spruce_side", "stenciltable_spruce_bottom", "stenciltable_birch_top", "stenciltable_birch_side",
"stenciltable_birch_bottom", "stenciltable_jungle_top", "stenciltable_jungle_side", "stenciltable_jungle_bottom" };
return textureNames;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon func_149691_a (int side, int meta)
{
if (meta <= 4)
{
return icons[meta * 3 + getTextureIndex(side)];
}
else if (meta <= 9)
{
return icons[15 + getTextureIndex(side)];
}
else
{
return icons[meta * 3 + getTextureIndex(side) - 12];
}
}
public int getTextureIndex (int side)
{
if (side == 0)
return 2;
if (side == 1)
return 0;
return 1;
}
@Override
public boolean func_149686_d ()
{
return false;
}
@Override
public boolean func_149662_c ()
{
return false;
}
@Override
public boolean isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side)
{
return side == ForgeDirection.UP;
}
@Override
public int func_149645_b ()
{
return TableRender.tabelModelID;
}
@Override
public boolean func_149646_a (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return true;
}
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
{
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 5)
return AxisAlignedBB.getAABBPool().getAABB((double) x + this.field_149759_B, (double) y + this.field_149760_C, (double) z + this.field_149754_D, (double) x + this.field_149755_E, (double) y + this.field_149756_F - 0.125, (double) z + this.field_149757_G);
return AxisAlignedBB.getAABBPool().getAABB((double) x + this.field_149759_B, (double) y + this.field_149760_C, (double) z + this.field_149754_D, (double) x + this.field_149755_E, (double) y + this.field_149756_F, (double) z + this.field_149757_G);
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
switch (metadata)
{
case 0:
return new ToolStationLogic();
case 1:
return new PartBuilderLogic();
case 2:
return new PartBuilderLogic();
case 3:
return new PartBuilderLogic();
case 4:
return new PartBuilderLogic();
case 5:
return new PatternChestLogic();
case 6:
return new PatternChestLogic();
case 7:
return new PatternChestLogic();
case 8:
return new PatternChestLogic();
case 9:
return new PatternChestLogic();
case 10:
return new StencilTableLogic();
case 11:
return new StencilTableLogic();
case 12:
return new StencilTableLogic();
case 13:
return new StencilTableLogic();
/*case 14:
return new CastingTableLogic();*/
default:
return null;
}
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
int md = world.getBlockMetadata(x, y, z);
if (md == 0)
return 0;
else if (md < 5)
return 1;
else if (md < 10)
return 2;
else
return 3;
//return -1;
}
@Override
public Object getModInstance ()
{
return TConstruct.instance;
}
@Override
public void func_149666_a (Item b, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 6; iter++)
{
list.add(new ItemStack(b, 1, iter));
}
for (int iter = 10; iter < 14; iter++)
{
list.add(new ItemStack(b, 1, iter));
}
}
@Override
public void func_149689_a (World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack)
{
if (PHConstruct.freePatterns)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 5)
{
PatternChestLogic logic = (PatternChestLogic) world.func_147438_o(x, y, z);
for (int i = 1; i <= 13; i++)
{
logic.setInventorySlotContents(i - 1, new ItemStack(TRepo.woodPattern, 1, i));
}
logic.setInventorySlotContents(13, new ItemStack(TRepo.woodPattern, 1, 22));
}
}
super.func_149689_a(world, x, y, z, par5EntityLiving, par6ItemStack);
}
@Override
public TileEntity func_149915_a (World var1, int var2)
{
return createTileEntity(var1,var2);
}
}