2015-01-11 11:47:36 +00:00
|
|
|
package com.cricketcraft.chisel.block;
|
|
|
|
|
|
2015-01-11 13:21:47 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
|
2015-01-11 11:47:36 +00:00
|
|
|
import net.minecraft.block.BlockTorch;
|
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
2015-01-15 13:09:34 -05:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2015-01-11 13:21:47 +00:00
|
|
|
import net.minecraft.world.World;
|
2015-01-11 11:47:36 +00:00
|
|
|
|
|
|
|
|
import com.cricketcraft.chisel.Chisel;
|
|
|
|
|
import com.cricketcraft.chisel.api.ICarvable;
|
2015-04-24 17:05:12 -04:00
|
|
|
import com.cricketcraft.chisel.api.carving.CarvableHelper;
|
2015-04-23 20:33:29 -04:00
|
|
|
import com.cricketcraft.chisel.api.carving.IVariationInfo;
|
2015-01-11 13:21:47 +00:00
|
|
|
import com.cricketcraft.chisel.init.ChiselTabs;
|
|
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-01-11 11:47:36 +00:00
|
|
|
|
2015-01-15 13:09:34 -05:00
|
|
|
public class BlockCarvableTorch extends BlockTorch implements ICarvable {
|
|
|
|
|
|
2015-01-11 13:21:47 +00:00
|
|
|
public CarvableHelper carverHelper;
|
|
|
|
|
private String texLocation;
|
|
|
|
|
protected boolean emitsParticles = true;
|
2015-04-06 01:16:14 -04:00
|
|
|
public int idx;
|
2015-01-11 11:47:36 +00:00
|
|
|
|
2015-04-06 01:16:14 -04:00
|
|
|
public BlockCarvableTorch(int idx, String tex) {
|
2015-01-11 13:21:47 +00:00
|
|
|
super();
|
2015-04-23 20:33:29 -04:00
|
|
|
carverHelper = new CarvableHelper(this);
|
2015-01-11 13:21:47 +00:00
|
|
|
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
|
|
|
|
setLightLevel(0.9375F);
|
|
|
|
|
setBlockName("torch");
|
2015-04-06 01:16:14 -04:00
|
|
|
this.idx = idx;
|
|
|
|
|
this.texLocation = tex;
|
2015-01-11 13:21:47 +00:00
|
|
|
}
|
2015-01-15 13:09:34 -05:00
|
|
|
|
2015-01-11 11:47:36 +00:00
|
|
|
@Override
|
2015-07-15 00:35:00 -04:00
|
|
|
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
|
2015-01-11 11:47:36 +00:00
|
|
|
return carverHelper.getVariation(metadata);
|
|
|
|
|
}
|
2015-01-15 13:09:34 -05:00
|
|
|
|
2015-01-11 11:47:36 +00:00
|
|
|
@Override
|
2015-07-15 00:35:00 -04:00
|
|
|
public IVariationInfo getManager(int meta) {
|
|
|
|
|
return carverHelper.getVariation(meta);
|
2015-01-11 13:21:47 +00:00
|
|
|
}
|
2015-01-15 13:09:34 -05:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void registerBlockIcons(IIconRegister icon) {
|
|
|
|
|
this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":torch/" + texLocation);
|
|
|
|
|
}
|
2015-08-06 00:00:22 -04:00
|
|
|
|
2015-01-15 13:09:34 -05:00
|
|
|
public BlockCarvableTorch disableParticles() {
|
2015-01-11 13:21:47 +00:00
|
|
|
this.emitsParticles = false;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2015-01-15 13:09:34 -05:00
|
|
|
|
2015-08-06 00:00:22 -04:00
|
|
|
@Override
|
2015-01-11 13:21:47 +00:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-01-15 13:09:34 -05:00
|
|
|
public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) {
|
|
|
|
|
if (emitsParticles) {
|
2015-01-11 13:21:47 +00:00
|
|
|
int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_);
|
2015-08-06 00:00:22 -04:00
|
|
|
double d0 = p_149734_2_ + 0.5F;
|
|
|
|
|
double d1 = p_149734_3_ + 0.7F;
|
|
|
|
|
double d2 = p_149734_4_ + 0.5F;
|
2015-01-11 13:21:47 +00:00
|
|
|
double d3 = 0.2199999988079071D;
|
|
|
|
|
double d4 = 0.27000001072883606D;
|
|
|
|
|
|
2015-01-15 13:09:34 -05:00
|
|
|
if (l == 1) {
|
2015-01-11 13:21:47 +00:00
|
|
|
p_149734_1_.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
|
|
|
|
p_149734_1_.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
2015-01-15 13:09:34 -05:00
|
|
|
} else if (l == 2) {
|
2015-01-11 13:21:47 +00:00
|
|
|
p_149734_1_.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
|
|
|
|
p_149734_1_.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
2015-01-15 13:09:34 -05:00
|
|
|
} else if (l == 3) {
|
2015-01-11 13:21:47 +00:00
|
|
|
p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
|
|
|
|
|
p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
|
2015-01-15 13:09:34 -05:00
|
|
|
} else if (l == 4) {
|
2015-01-11 13:21:47 +00:00
|
|
|
p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
|
|
|
|
|
p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
|
2015-01-15 13:09:34 -05:00
|
|
|
} else {
|
2015-01-11 13:21:47 +00:00
|
|
|
p_149734_1_.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
|
|
|
|
p_149734_1_.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-11 11:47:36 +00:00
|
|
|
}
|