-
Notifications
You must be signed in to change notification settings - Fork 754
/
PaneBase.java
188 lines (170 loc) · 5.72 KB
/
PaneBase.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
package tconstruct.blocks;
import java.util.List;
import tconstruct.client.block.PaneRender;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPane;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PaneBase extends Block
{
public String[] textureNames;
public String folder;
public IIcon[] icons;
public IIcon[] sideIcons;
public PaneBase(Material material, String folder, String[] blockTextures)
{
super(material);
textureNames = blockTextures;
this.folder = folder;
}
public boolean canConnectTo (Block block2)
{
Block block = block2;
return Block.opaqueCubeLookup[block2] || block instanceof PaneBase || block instanceof BlockPane || block2 == Blocks.glass;
}
public IIcon getSideTextureIndex (int meta)
{
return sideIcons[meta];
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IIconRegister iconRegister)
{
this.icons = new IIcon[textureNames.length];
this.sideIcons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]);
this.sideIcons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i] + "_side");
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
return icons[meta];
}
@Override
public void getSubBlocks (Item b, CreativeTabs tab, List list)
{
for (int iter = 0; iter < textureNames.length; iter++)
{
list.add(new ItemStack(b, 1, iter));
}
}
public boolean isOpaqueCube ()
{
return false;
}
public boolean renderAsNormalBlock ()
{
return false;
}
public int getRenderType ()
{
return PaneRender.model;
}
public boolean func_149646_a (IBlockAccess iblockaccess, int i, int j, int k, int l)
{
Block b = iblockaccess.func_147439_a(i, j, k);
if (b instanceof PaneBase || b instanceof BlockPane)
{
return false;
}
else
{
return super. func_149646_a(iblockaccess, i, j, k, l);
}
}
@Override
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity)
{
boolean south = canConnectTo(world.func_147439_a(x, y, z - 1));
boolean north = canConnectTo(world.func_147439_a(x, y, z + 1));
boolean east = canConnectTo(world.func_147439_a(x - 1, y, z));
boolean west = canConnectTo(world.func_147439_a(x + 1, y, z));
if (east && west || !east && !west && !south && !north)
{
setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
}
else if (east && !west)
{
setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
}
else if (!east && west)
{
setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
}
if (south && north || !east && !west && !south && !north)
{
setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
}
else if (south && !north)
{
setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
}
else if (!south && north)
{
setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
}
}
public void setBlockBoundsForItemRender ()
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void setBlockBoundsBasedOnState (IBlockAccess iblockaccess, int i, int j, int k)
{
float f = 0.4375F;
float f1 = 0.5625F;
float f2 = 0.4375F;
float f3 = 0.5625F;
boolean flag = canConnectTo(iblockaccess.func_147439_a(i, j, k - 1));
boolean flag1 = canConnectTo(iblockaccess.func_147439_a(i, j, k + 1));
boolean flag2 = canConnectTo(iblockaccess.func_147439_a(i - 1, j, k));
boolean flag3 = canConnectTo(iblockaccess.func_147439_a(i + 1, j, k));
if (flag2 && flag3 || !flag2 && !flag3 && !flag && !flag1)
{
f = 0.0F;
f1 = 1.0F;
}
else if (flag2 && !flag3)
{
f = 0.0F;
}
else if (!flag2 && flag3)
{
f1 = 1.0F;
}
if (flag && flag1 || !flag2 && !flag3 && !flag && !flag1)
{
f2 = 0.0F;
f3 = 1.0F;
}
else if (flag && !flag1)
{
f2 = 0.0F;
}
else if (!flag && flag1)
{
f3 = 1.0F;
}
setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
}
}