-
Notifications
You must be signed in to change notification settings - Fork 755
/
FurnaceSlab.java
183 lines (161 loc) · 5.43 KB
/
FurnaceSlab.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
package tconstruct.tools.blocks;
import java.util.Random;
import mantle.blocks.abstracts.InventorySlab;
import mantle.blocks.iface.IActiveLogic;
import mantle.blocks.iface.IFacingLogic;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import tconstruct.TConstruct;
import tconstruct.library.TConstructRegistry;
import tconstruct.tools.ToolProxyCommon;
import tconstruct.tools.logic.FurnaceLogic;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class FurnaceSlab extends InventorySlab
{
public FurnaceSlab(Material material)
{
super(material);
this.setCreativeTab(TConstructRegistry.blockTab);
this.setHardness(3.5f);
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
switch (metadata % 8)
{
case 0:
return new FurnaceLogic();
}
return null;
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
return ToolProxyCommon.furnaceID;
}
@Override
public Object getModInstance ()
{
return TConstruct.instance;
}
@Override
public String[] getTextureNames ()
{
String[] textureNames = { "furnaceslab_front", "furnaceslab_front_active", "furnaceslab_side", "furnace_top" };
return textureNames;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (int side, int meta)
{
return icons[(meta % 8) * 3 + getTextureIndex(side)];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon (IBlockAccess world, int x, int y, int z, int side)
{
TileEntity logic = world.getTileEntity(x, y, z);
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0;
int meta = world.getBlockMetadata(x, y, z) % 8;
if (meta == 0)
{
if (side == direction)
{
if (((IActiveLogic) logic).getActive())
return icons[1];
else
return icons[0];
}
else if (side > 1)
{
return icons[2];
}
return icons[3];
}
return icons[0];
}
public int getTextureIndex (int side)
{
if (side == 0 || side == 1)
return 3;
if (side == 3)
return 0;
return 2;
}
@Override
public String getTextureDomain (int textureNameIndex)
{
return "tinker";
}
@Override
public void registerBlockIcons (IIconRegister iconRegister)
{
String[] textureNames = getTextureNames();
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
if (i == 3)
this.icons[i] = iconRegister.registerIcon("minecraft:" + textureNames[i]);
else
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
}
}
@Override
public TileEntity createNewTileEntity (World var1, int metadata)
{
switch (metadata % 8)
{
case 0:
return new FurnaceLogic();
}
return null;
}
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick (World world, int x, int y, int z, Random random)
{
TileEntity logic = world.getTileEntity(x, y, z);
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0;
int meta = world.getBlockMetadata(x, y, z);
int metaType = meta % 8;
int metaPos = meta / 8;
if (metaType == 0)
{
if (((IActiveLogic) logic).getActive())
{
float offset = random.nextFloat() * 0.6F - 0.3F;
float offsetY = random.nextFloat() * 6.0F / 16.0F;
if (metaPos == 1)
{
offsetY += 0.5F;
}
if (direction == 4)
{
world.spawnParticle("smoke", x, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
}
else if (direction == 5)
{
world.spawnParticle("smoke", x + 1.0F, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 1.0F, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
}
else if (direction == 2)
{
world.spawnParticle("smoke", x + offset + 0.5F, y + offsetY, z, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + offset + 0.5F, y + offsetY, z, 0.0D, 0.0D, 0.0D);
}
else if (direction == 3)
{
world.spawnParticle("smoke", x + offset + 0.5F, y + offsetY, z + 1.0F, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + offset + 0.5F, y + offsetY, z + 1.0F, 0.0D, 0.0D, 0.0D);
}
}
}
}
}