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.item.ItemStack;
|
|
|
|
|
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;
|
|
|
|
|
import com.cricketcraft.chisel.carving.CarvableHelper;
|
|
|
|
|
import com.cricketcraft.chisel.carving.CarvableVariation;
|
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-01-11 11:47:36 +00:00
|
|
|
|
2015-01-15 13:09:34 -05:00
|
|
|
public BlockCarvableTorch() {
|
2015-01-11 13:21:47 +00:00
|
|
|
super();
|
|
|
|
|
carverHelper = new CarvableHelper();
|
|
|
|
|
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
|
|
|
|
|
setLightLevel(0.9375F);
|
|
|
|
|
setBlockName("torch");
|
|
|
|
|
}
|
2015-01-15 13:09:34 -05:00
|
|
|
|
2015-01-11 11:47:36 +00:00
|
|
|
@Override
|
2015-01-15 13:09:34 -05:00
|
|
|
public CarvableVariation getVariation(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-01-15 13:09:34 -05:00
|
|
|
public CarvableVariation getVariation(ItemStack stack) {
|
|
|
|
|
return carverHelper.getVariation(stack.getItemDamage());
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setInformation(String textureLocation) {
|
2015-01-11 13:21:47 +00:00
|
|
|
this.texLocation = textureLocation;
|
|
|
|
|
}
|
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-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-01-15 13:09:34 -05:00
|
|
|
double d0 = (double) ((float) p_149734_2_ + 0.5F);
|
|
|
|
|
double d1 = (double) ((float) p_149734_3_ + 0.7F);
|
|
|
|
|
double d2 = (double) ((float) 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
|
|
|
}
|