Solved Change Block Explosion Resistance [1.8.8 or 1.15.2]

Discussion in 'Plugin Development' started by Xp10d3, Sep 10, 2020.

  1. Offline

    Xp10d3

    Okay, I've done quite a bit of research but none of them have worked so far I think in 1.8, but if there is a thread I haven't seen please send it :p Anyways, I want to change the block resistance on certain blocks within a condition. Here is some psuedo code to explain what I mean:
    Code:java
    1.  
    2. int rng = random_num_generator_or_whatever;
    3. if (rng = 5) {
    4. // Change block resistance of a block
    5. } else {
    6. return;
    7. }
    8.  

    And by block resistance, I mean stuff like TNT. I want to add this plugin to both my MMORPG and Factions server. Both will likely have TNT (especially Factions) and I want there to be some perks for certain players (ranked players, those with a specific class, etc.) that involves explosions and breaking blocks. And yes, the RPG is 1.8 and Factions is 1.15.2. Anyways, I just need an updated way to change the resistance of a block. I don't have any code at the moment.
     
  2. Offline

    Kars

    You could use either of these, not sure which:
    https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockExplodeEvent.html
    https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityExplodeEvent.html

    1. Get the blocks that exploded with blockList -> save them and their locations
    2. After the event completes (delayed runnable 1 tick), do your logic. If you determine the block shouldn't have exploded, place the block back.
    You might also want to set the yield to 0 so you don't end up duping blocks.

    That doesn't use blast resistance but it will achieve your goal
     
    Xp10d3 likes this.
  3. Offline

    Xp10d3

    Thank you! That was helpful :) I'll try that out. Marking as solved for now.
     

Share This Page