oneofthem999

KillBlock

Jun 11th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. public class KillBlock extends Block
  2. {
  3. //Constructor
  4. public KillBlock()
  5. {
  6. super(Material.IRON);
  7. this.setUnlocalizedName("killBlock");
  8. this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
  9. this.setResistance(5.0F);
  10. this.setHardness(5.0F);
  11. this.setLightLevel(0.1F);
  12. this.setHarvestLevel("pickaxe", 1);
  13. }
  14.  
  15. /**
  16. * This method will return the bounding box of the kill block;
  17. */
  18. @Override
  19. public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
  20. {
  21. AxisAlignedBB axis = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.875D, 1.0D);
  22. return axis;
  23. }
  24.  
  25. /**
  26. * This method will check whether or not the block has been collied with vertically. If so, it will kill the
  27. * player if it doesn't have the protective aura.
  28. */
  29. public void onEntityCollidedWithBlock(World world, BlockPos pos, Entity entity)
  30. {
  31. //System.out.println("onEntityColliededWithBlock checkpoint 1");
  32. if (!(entity instanceof EntityPlayer))
  33. {
  34. //System.out.println("onEntityColliededWithBlock checkpoint 1a");
  35. return;
  36. }
  37.  
  38. //System.out.println("onEntityColliededWithBlock checkpoint 2");
  39. EntityPlayer player = (EntityPlayer) entity;
  40.  
  41. //System.out.println("onEntityColliededWithBlock checkpoint 3");
  42. if (!player.isCollidedVertically)
  43. {
  44. //System.out.println("onEntityColliededWithBlock checkpoint 3a");
  45. return;
  46. }
  47.  
  48. else
  49. {
  50. //System.out.println("onEntityColliededWithBlock checkpoint 4");
  51. if (!player.isPotionActive(Main.auraPotion))
  52. {
  53. //System.out.println("onEntityColliededWithBlock checkpoint 5");
  54. player.attackEntityFrom(DamageSource.generic, 50);
  55. }
  56. }
  57. }
  58. }
Add Comment
Please, Sign In to add comment