Change block durability?

Discussion in 'Plugin Development' started by Creeoer, Jan 11, 2015.

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

    Creeoer

    I want to make a block indesturctible, can't seem to find a method that can modify the durablity to something like 999999 or just not destructible, any help?
     
  2. Invisible

    nverdier

    @Creeoer Do you want a type of block, or just one specific block.
     
  3. Offline

    Creeoer

    @nverdier
    I'm iterating through a block list, so I'm just using those objects to do this on.
     
  4. Invisible

    nverdier

    @Creeoer Well I suppose you could have events for every way to break a block and if the block is one of those, then cancel it... I really hope there is a better way :p
     
  5. Offline

    teej107

    PlayerInteractEvent. Get the block, set the durability.
     
  6. Invisible

    nverdier

  7. Offline

    567legodude

    @nverdier @Creeoer
    For explosions, listen for EntityExplodeEvent
    you can get a list of the affected blocks by calling event.blockList() which returns List<Block>
     
  8. Offline

    Creeoer

    I know, I've done that. The question is how to change the durability of those blocks
     
  9. Offline

    567legodude

    @Creeoer I don't think you can change it, but you can cancel the breaking of that block.
     
  10. Offline

    Creeoer

    @567legodude
    Is there any other way to do that besides removing it from the e.Blocklist?
     
  11. Offline

    567legodude

    @Creeoer From my search, it looks like you can't modify the durability of a block unless you modify the actual game itself.
     
  12. Invisible

    nverdier

    @567legodude @Creeoer You could somehow make the block look like another block but have the properties of the block it actually is, so you could have bedrock look like stone, for example, and it wouldn't break.
     
  13. Offline

    567legodude

    @nverdier That sounds like you would need packets. I have never used packets, and I also don't know how to use them.
     
  14. Invisible

    nverdier

    @567legodude Yeah I'm not sure, but I think it would need them as well. Best thing so far I think to do is just cancel the events.
     
  15. Offline

    mythbusterma

    @567legodude

    Why would you need packets, again? Explosions are handled server side.

    All you would need to do is modify the property of a Material to have a different explosion resistance, or modify the code for explosions.
     
  16. Invisible

    nverdier

    @mythbusterma Packets to
    :p
     
  17. Offline

    567legodude

    @mythbusterma
    I was referencing the below statement. Not the part about explosions.
     
  18. Offline

    unrealdesign

    Unless you consider Player#sendBlockChange() packets, then no.
     
Thread Status:
Not open for further replies.

Share This Page