Files
Chisel/src/main/java/com/cricketcraft/chisel/block/BlockCarvableTorch.java
T

85 lines
2.9 KiB
Java
Raw Normal View History

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;
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
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();
carverHelper = new CarvableHelper();
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-11 11:47:36 +00:00
@Override
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-11 11:47:36 +00:00
@Override
public CarvableVariation getVariation(ItemStack stack) {
return carverHelper.getVariation(stack.getItemDamage());
2015-01-11 13:21:47 +00:00
}
@Override
public void registerBlockIcons(IIconRegister icon) {
this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":torch/" + texLocation);
}
2015-04-06 01:16:14 -04:00
public BlockCarvableTorch disableParticles() {
2015-01-11 13:21:47 +00:00
this.emitsParticles = false;
return this;
}
2015-01-11 13:21:47 +00:00
@SideOnly(Side.CLIENT)
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_);
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;
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);
} 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);
} 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);
} 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);
} 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
}