Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class KillBlock extends Block
- {
- //Constructor
- public KillBlock()
- {
- super(Material.IRON);
- this.setUnlocalizedName("killBlock");
- this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
- this.setResistance(5.0F);
- this.setHardness(5.0F);
- this.setLightLevel(0.1F);
- this.setHarvestLevel("pickaxe", 1);
- }
- /**
- * This method will return the bounding box of the kill block;
- */
- @Override
- public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
- {
- AxisAlignedBB axis = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.875D, 1.0D);
- return axis;
- }
- /**
- * This method will check whether or not the block has been collied with vertically. If so, it will kill the
- * player if it doesn't have the protective aura.
- */
- public void onEntityCollidedWithBlock(World world, BlockPos pos, Entity entity)
- {
- //System.out.println("onEntityColliededWithBlock checkpoint 1");
- if (!(entity instanceof EntityPlayer))
- {
- //System.out.println("onEntityColliededWithBlock checkpoint 1a");
- return;
- }
- //System.out.println("onEntityColliededWithBlock checkpoint 2");
- EntityPlayer player = (EntityPlayer) entity;
- //System.out.println("onEntityColliededWithBlock checkpoint 3");
- if (!player.isCollidedVertically)
- {
- //System.out.println("onEntityColliededWithBlock checkpoint 3a");
- return;
- }
- else
- {
- //System.out.println("onEntityColliededWithBlock checkpoint 4");
- if (!player.isPotionActive(Main.auraPotion))
- {
- //System.out.println("onEntityColliededWithBlock checkpoint 5");
- player.attackEntityFrom(DamageSource.generic, 50);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment