-
Notifications
You must be signed in to change notification settings - Fork 754
/
GlassBlockConnectedMeta.java
102 lines (89 loc) · 4.13 KB
/
GlassBlockConnectedMeta.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
package tconstruct.blocks;
import java.util.List;
import tconstruct.util.config.PHConstruct;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
/** @author fuj1n
*
*/
public class GlassBlockConnectedMeta extends GlassBlockConnected
{
public String[] textures;
public IIcon[][] icons;
boolean ignoreMetaForConnectedGlass = PHConstruct.connectedTexturesMode == 2;
public GlassBlockConnectedMeta(int par1, String location, boolean hasAlpha, String... textures)
{
super(par1, location, hasAlpha);
this.textures = textures;
this.icons = new IIcon[textures.length][16];
}
@Override
public IIcon getBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
if (meta < icons.length)
{
return getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons[meta]);
}
else
{
return getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons[0]);
}
}
@Override
public boolean shouldConnectToBlock (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, int par6)
{
return par5 == this.blockID && (par6 == par1IBlockAccess.getBlockMetadata(par2, par3, par4) || ignoreMetaForConnectedGlass);
}
@Override
public IIcon getIcon (int par1, int par2)
{
return icons[par2][0];
}
@Override
public void getSubBlocks (Block b, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < textures.length; i++)
{
par3List.add(new ItemStack(b, 1, i));
}
}
@Override
public void registerIcons (IIconRegister par1IconRegister)
{
for (int i = 0; i < textures.length; i++)
{
icons[i][0] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass");
icons[i][1] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_d");
icons[i][2] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_u");
icons[i][3] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_l");
icons[i][4] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_r");
icons[i][5] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_h");
icons[i][6] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_v");
icons[i][7] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_dl");
icons[i][8] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_dr");
icons[i][9] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_ul");
icons[i][10] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_ur");
icons[i][11] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_d");
icons[i][12] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_u");
icons[i][13] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_l");
icons[i][14] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_r");
icons[i][15] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_4");
}
}
@Override
public int damageDropped (int par1)
{
return par1;
}
@Override
public boolean canPlaceTorchOnTop (World world, int x, int y, int z)
{
return true;
}
}