Files
TinkersConstruct/src/main/java/tconstruct/tools/blocks/FurnaceSlab.java
T

143 lines
4.9 KiB
Java
Raw Normal View History

2014-06-04 21:44:48 -08:00
package tconstruct.tools.blocks;
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.*;
import net.minecraft.block.material.Material;
2013-12-31 11:26:08 -05:00
import net.minecraft.client.renderer.texture.IIconRegister;
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.*;
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;
public class FurnaceSlab extends InventorySlab {
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);
}
@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) {
2014-06-06 19:46:05 -08:00
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
2014-02-17 15:30:13 -05:00
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
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)
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);
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();
2013-12-31 15:30:34 -05:00
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]);
}
}
2014-01-15 23:19:27 -05:00
@Override
public TileEntity createNewTileEntity(World var1, int metadata) {
switch (metadata % 8) {
case 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
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;
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
if (metaPos == 1) {
2014-09-06 19:58:54 +02:00
offsetY += 0.5F;
}
2014-09-09 18:30:15 +10:00
if (direction == 4) {
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);
} else if (direction == 5) {
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);
} else if (direction == 2) {
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);
} else if (direction == 3) {
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
}
}
}
}