- 83
- 0
Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
public class BonfireBlock extends BlockContainer {
public static boolean active;
public BonfireBlock() {
super(Material.redstoneLight);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setBlockName("bonfire");
this.setLightLevel(active?2.0F:0.0F);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
public int getRenderType() {return -1;}
public boolean renderAsNormalBlock() {return false;}
public boolean isOpaqueCube() {return false;}
@Override
public TileEntity createNewTileEntity(World world,int i) {return new TEBonfire();}
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.2F, 1.0F);
}
@Override
public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_,
int p_149670_3_, int p_149670_4_, Entity ent) {
ent.attackEntityFrom(DamageSource.inFire, 5);
}
@Override
public boolean onBlockActivated(World world, int x,int y, int z, EntityPlayer ep,int meta, float hitX, float hitY,float hitZ_) {
if(world.isRemote){
return true;
}else{
ep.openGui( Core.mod, 0, world, x, y, z);
}
return true;
}
public void randomDisplayTick(World world, int x,int y, int z, Random rand) {
if(active){particles(world, x, y, z, rand);}
}
public void particles(World world, int x,int y, int z, Random rand) {
double d1 = (double)(rand.nextInt(2)/10);
world.spawnParticle("flame", (double)(x+0.5), (double)y, (double)(z+0.5), 0.0D, 0.06D, 0.0D);
world.spawnParticle("flame", (double)(x+0.3), (double)y, (double)(z+0.3), 0.0D, 0.04D, 0.0D);
world.spawnParticle("flame", (double)(x+0.7), (double)y, (double)(z+0.7), 0.0D, 0.04D, 0.0D);
world.spawnParticle("flame", (double)(x+0.3), (double)y, (double)(z+0.7), 0.0D, 0.04D, 0.0D);
world.spawnParticle("flame", (double)(x+0.7), (double)y, (double)(z+0.3), 0.0D, 0.04D, 0.0D);
world.spawnParticle("smoke", (double)(x+0.51), (double)y, (double)(z+0.51), 0.0D, 0.06D, 0.0D);
world.spawnParticle("smoke", (double)(x+0.35), (double)y, (double)(z+0.35), 0.0D, 0.04D, 0.0D);
world.spawnParticle("smoke", (double)(x+0.65), (double)y, (double)(z+0.35), 0.0D, 0.04D, 0.0D);
world.spawnParticle("smoke", (double)(x+0.35), (double)y, (double)(z+0.65), 0.0D, 0.04D, 0.0D);
world.spawnParticle("smoke", (double)(x+0.65), (double)y, (double)(z+0.65), 0.0D, 0.04D, 0.0D);
}
@Override
public void onBlockPlacedBy(World world, int x,int y, int z, EntityLivingBase ent,ItemStack is) {
if(is.hasDisplayName()){
((TEBonfire)world.getTileEntity(x, y, z)).setGuiDisplayName(is.getDisplayName());
}
}
public static void updateBonfireBlockState(boolean b, World worldObj,int xCoord, int yCoord, int zCoord) {
active = b;
}
}