Block Damage Control

Discussion in 'Plugin Development' started by csma-cd, Mar 12, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    csma-cd

    Hello,

    Is there any numerical data of the block's resistence or "health" that can be treated on BLOCK_DAMAGE event?

    Regards,

    CSMA-CD
     
  2. Offline

    Edward Hand

    Give this a go (making sure you have CraftBukkit added to your build path):
    Code:
    CraftPlayer cPlayer = (CraftPlayer)event.getPlayer();
    float damageLevel = cPlayer.getHandle().c.c;
    This returns a value between 0.0F and 1.0F (0 being full health and 1 being completely destroyed)
    If you need to know how many more hits it can take:
    Code:
    int hitsRemaining = Math.ceil((1-damageLevel)/Block.byId[event.getBlock().getTypeId()].a(cPlayer.getHandle()));
    Hope that helps.
     
  3. Offline

    csma-cd

    KEWL!!! Really fun... Thanks!
     
Thread Status:
Not open for further replies.

Share This Page