Advertisement
robin4002

Untitled

Jun 29th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.57 KB | None | 0 0
  1. package fr.mcnanotech.kevin_68.nanotech_mod.blocks;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.block.material.Material;
  5. import net.minecraft.client.renderer.texture.IconRegister;
  6. import net.minecraft.entity.Entity;
  7. import net.minecraft.entity.EntityLiving;
  8. import net.minecraft.entity.item.EntityTNTPrimed;
  9. import net.minecraft.util.AxisAlignedBB;
  10. import net.minecraft.util.DamageSource;
  11. import net.minecraft.world.Explosion;
  12. import net.minecraft.world.World;
  13.  
  14. public class BlockSodium extends Block
  15. {
  16.     public BlockSodium(int id, Material material)
  17.     {
  18.         super(id, material);
  19.     }
  20.    
  21.     public void registerIcons(IconRegister iconregister)
  22.     {
  23.         blockIcon = iconregister.registerIcon("Nanotech_mod:sodium");
  24.     }
  25.  
  26.     public void onBlockAdded(World world, int x, int y, int z)
  27.     {
  28.         super.onBlockAdded(world, x, y, z);
  29.         this.checkdoexplode(world, x, y, z);
  30.     }
  31.  
  32.     public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
  33.     {
  34.         float var5 = 0.0625F;
  35.         return AxisAlignedBB.getAABBPool().getAABB((double) ((float) x + var5), (double) y, (double) ((float) z + var5), (double) ((float) (x + 1) - var5), (double) ((float) (y + 1) - var5), (double) ((float) (z + 1) - var5));
  36.     }
  37.  
  38.     public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
  39.     {
  40.         if (entity instanceof EntityLiving)
  41.         {
  42.             entity.attackEntityFrom(DamageSource.cactus, 1);
  43.         }
  44.     }
  45.  
  46.     public void onNeighborBlockChange(World world, int x, int y, int z, int par5)
  47.     {
  48.         super.onNeighborBlockChange(world, x, y, z, par5);
  49.         this.checkdoexplode(world, x, y, z);
  50.     }
  51.    
  52.     public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion)
  53.     {
  54.         if (!world.isRemote)
  55.         {
  56.             world.setBlockToAir(x, y, z);
  57.             float power = (float)world.rand.nextInt(10) - 5.5F;
  58.             if(power < 2.5F)
  59.             {
  60.                 power = 5F;
  61.             }
  62.             EntityTNTPrimed tnt = new EntityTNTPrimed(world);
  63.             world.createExplosion(tnt, x, y, z, power, true);
  64.             world.notifyBlockChange(x, y, z, 0);
  65.         }
  66.     }
  67.    
  68.     public void checkdoexplode(World world, int x, int y, int z)
  69.     {
  70.         if (world.getBlockId(x, y - 1, z) == Block.waterStill.blockID || world.getBlockId(x, y + 1, z) == Block.waterStill.blockID || world.getBlockId(x - 1, y, z) == Block.waterStill.blockID || world.getBlockId(x + 1, y, z) == Block.waterStill.blockID || world.getBlockId(x, y, z - 1) == Block.waterStill.blockID || world.getBlockId(x, y, z + 1) == Block.waterStill.blockID || world.getBlockId(x, y - 1, z) == Block.waterMoving.blockID || world.getBlockId(x, y + 1, z) == Block.waterMoving.blockID || world.getBlockId(x - 1, y, z) == Block.waterMoving.blockID || world.getBlockId(x + 1, y, z) == Block.waterMoving.blockID || world.getBlockId(x, y, z - 1) == Block.waterMoving.blockID || world.getBlockId(x, y, z + 1) == Block.waterMoving.blockID)
  71.         {
  72.             if (!world.isRemote)
  73.             {
  74.                 world.setBlockToAir(x, y, z);
  75.                 float power = (float)world.rand.nextInt(15) - 5.5F;
  76.                 if(power < 2.5F)
  77.                 {
  78.                     power = 5F;
  79.                 }
  80.                 EntityTNTPrimed tnt = new EntityTNTPrimed(world);
  81.                 world.newExplosion(tnt, x, y, z, power, true, true);
  82.                 world.notifyBlockChange(x, y, z, 0);
  83.             }
  84.         }
  85.        
  86.         if (world.isAirBlock(x, y - 1, z) || world.isAirBlock(x, y + 1, z) || world.isAirBlock(x - 1, y, z) || world.isAirBlock(x + 1, y, z) || world.isAirBlock(x, y, z - 1) || world.isAirBlock(x, y, z + 1))
  87.         {
  88.             if (!world.isRemote)
  89.             {
  90.                 int i = world.rand.nextInt(2);
  91.                 if(world.isAirBlock(x, y + 1, z) && i == 1)
  92.                 {
  93.                     world.setBlock(x, y + 1, z, Block.fire.blockID, 0, 3);
  94.                 }
  95.             }
  96.         }
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement