2014-06-04 21:44:48 -08:00
|
|
|
package tconstruct.tools.blocks;
|
2013-11-09 14:28:48 -08:00
|
|
|
|
2014-09-09 18:30:15 +10:00
|
|
|
import cpw.mods.fml.relauncher.*;
|
2014-09-06 19:58:54 +02:00
|
|
|
import java.util.Random;
|
2014-02-05 10:28:54 -05:00
|
|
|
import mantle.blocks.abstracts.InventorySlab;
|
2014-09-09 18:30:15 +10:00
|
|
|
import mantle.blocks.iface.*;
|
2013-11-09 14:28:48 -08:00
|
|
|
import net.minecraft.block.material.Material;
|
2013-12-31 11:26:08 -05:00
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
2013-11-09 14:28:48 -08:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2013-12-31 11:26:08 -05:00
|
|
|
import net.minecraft.util.IIcon;
|
2014-09-09 18:30:15 +10:00
|
|
|
import net.minecraft.world.*;
|
2013-11-09 14:28:48 -08:00
|
|
|
import tconstruct.TConstruct;
|
|
|
|
|
import tconstruct.library.TConstructRegistry;
|
2014-06-06 19:46:05 -08:00
|
|
|
import tconstruct.tools.ToolProxyCommon;
|
2014-06-04 21:44:48 -08:00
|
|
|
import tconstruct.tools.logic.FurnaceLogic;
|
2013-11-09 14:28:48 -08:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public class FurnaceSlab extends InventorySlab {
|
2013-11-09 14:28:48 -08:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public FurnaceSlab(Material material) {
|
2013-12-31 11:26:08 -05:00
|
|
|
super(material);
|
2014-02-05 08:28:53 -05:00
|
|
|
this.setCreativeTab(TConstructRegistry.blockTab);
|
|
|
|
|
this.setHardness(3.5f);
|
2013-11-09 14:28:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public TileEntity createTileEntity(World world, int metadata) {
|
2023-01-25 23:03:02 +01:00
|
|
|
if (metadata % 8 == 0) {
|
|
|
|
|
return new FurnaceLogic();
|
2013-11-09 14:28:48 -08:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer) {
|
2014-06-06 19:46:05 -08:00
|
|
|
return ToolProxyCommon.furnaceID;
|
2013-11-09 14:28:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public Object getModInstance() {
|
2013-11-09 14:28:48 -08:00
|
|
|
return TConstruct.instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public String[] getTextureNames() {
|
2023-01-25 22:43:06 +01:00
|
|
|
return new String[]{"furnaceslab_front", "furnaceslab_front_active", "furnaceslab_side", "furnace_top"};
|
2013-11-09 14:28:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-02-17 15:30:13 -05:00
|
|
|
@SideOnly(Side.CLIENT)
|
2022-09-22 19:51:23 +01:00
|
|
|
public IIcon getIcon(int side, int meta) {
|
2013-11-09 14:28:48 -08:00
|
|
|
return icons[(meta % 8) * 3 + getTextureIndex(side)];
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2014-02-17 15:30:13 -05:00
|
|
|
@SideOnly(Side.CLIENT)
|
2022-09-22 19:51:23 +01:00
|
|
|
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
2014-02-05 08:28:53 -05:00
|
|
|
TileEntity logic = world.getTileEntity(x, y, z);
|
2013-11-09 14:28:48 -08:00
|
|
|
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0;
|
|
|
|
|
int meta = world.getBlockMetadata(x, y, z) % 8;
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
if (meta == 0) {
|
|
|
|
|
if (side == direction) {
|
|
|
|
|
if (((IActiveLogic) logic).getActive()) return icons[1];
|
|
|
|
|
else return icons[0];
|
|
|
|
|
} else if (side > 1) {
|
2013-11-09 14:28:48 -08:00
|
|
|
return icons[2];
|
|
|
|
|
}
|
|
|
|
|
return icons[3];
|
|
|
|
|
}
|
|
|
|
|
return icons[0];
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public int getTextureIndex(int side) {
|
|
|
|
|
if (side == 0 || side == 1) return 3;
|
|
|
|
|
if (side == 3) return 0;
|
2013-11-09 14:28:48 -08:00
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-27 15:27:44 -05:00
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public String getTextureDomain(int textureNameIndex) {
|
2014-02-27 15:27:44 -05:00
|
|
|
return "tinker";
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-09 14:28:48 -08:00
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public void registerBlockIcons(IIconRegister iconRegister) {
|
2013-11-09 14:28:48 -08:00
|
|
|
String[] textureNames = getTextureNames();
|
2013-12-31 15:30:34 -05:00
|
|
|
this.icons = new IIcon[textureNames.length];
|
2013-11-09 14:28:48 -08:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
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]);
|
2013-11-09 14:28:48 -08:00
|
|
|
}
|
|
|
|
|
}
|
2014-01-15 23:19:27 -05:00
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public TileEntity createNewTileEntity(World var1, int metadata) {
|
2023-01-25 23:03:02 +01:00
|
|
|
if (metadata % 8 == 0) {
|
|
|
|
|
return new FurnaceLogic();
|
2014-01-15 23:19:27 -05:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2014-09-06 19:58:54 +02:00
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
|
2014-09-06 19:58:54 +02:00
|
|
|
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;
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
if (metaType == 0) {
|
|
|
|
|
if (((IActiveLogic) logic).getActive()) {
|
2014-09-06 19:58:54 +02:00
|
|
|
float offset = random.nextFloat() * 0.6F - 0.3F;
|
|
|
|
|
float offsetY = random.nextFloat() * 6.0F / 16.0F;
|
2014-09-09 18:30:15 +10:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
if (metaPos == 1) {
|
2014-09-06 19:58:54 +02:00
|
|
|
offsetY += 0.5F;
|
|
|
|
|
}
|
2014-09-09 18:30:15 +10:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
if (direction == 4) {
|
2014-09-06 20:39:11 +02:00
|
|
|
world.spawnParticle("smoke", x - 0.02F, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
|
|
|
|
|
world.spawnParticle("flame", x - 0.02F, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
|
2022-09-22 19:51:23 +01:00
|
|
|
} else if (direction == 5) {
|
2014-09-06 20:39:11 +02:00
|
|
|
world.spawnParticle("smoke", x + 1.02F, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
|
|
|
|
|
world.spawnParticle("flame", x + 1.02F, y + offsetY, z + offset + 0.5F, 0.0D, 0.0D, 0.0D);
|
2022-09-22 19:51:23 +01:00
|
|
|
} else if (direction == 2) {
|
2014-09-06 20:39:11 +02:00
|
|
|
world.spawnParticle("smoke", x + offset + 0.5F, y + offsetY, z - 0.02F, 0.0D, 0.0D, 0.0D);
|
|
|
|
|
world.spawnParticle("flame", x + offset + 0.5F, y + offsetY, z - 0.02F, 0.0D, 0.0D, 0.0D);
|
2022-09-22 19:51:23 +01:00
|
|
|
} else if (direction == 3) {
|
2014-09-06 20:39:11 +02:00
|
|
|
world.spawnParticle("smoke", x + offset + 0.5F, y + offsetY, z + 1.02F, 0.0D, 0.0D, 0.0D);
|
|
|
|
|
world.spawnParticle("flame", x + offset + 0.5F, y + offsetY, z + 1.02F, 0.0D, 0.0D, 0.0D);
|
2014-09-09 18:30:15 +10:00
|
|
|
}
|
2014-09-06 19:58:54 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-09 14:28:48 -08:00
|
|
|
}
|