Skip to content

Commit

Permalink
feat: onExplode customization on EnergyNetProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 committed Nov 20, 2024
1 parent d12ae85 commit 51a1d1b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import javax.annotation.Nonnull;

import org.bukkit.Location;
import org.bukkit.Material;

import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;

Expand Down Expand Up @@ -63,4 +65,21 @@ default boolean willExplode(@Nonnull Location l, @Nonnull Config data) {
return false;
}

/**
* This method determines what happens when the {@link Location} of
* this {@link EnergyNetProvider} is going to explode.
* <br>
* Note: This method is called async.
* The actual block is still there but the Slimefun block data is removed.
*
* @param l
* The {@link Location} of this {@link EnergyNetProvider}
*/
default void onExplode(@Nonnull Location l) {
Slimefun.runSync(() -> {
l.getBlock().setType(Material.LAVA);
l.getWorld().createExplosion(l, 0F, false);
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,7 @@ private int tickAllGenerators(@Nonnull LongConsumer timings) {
explodedBlocks.add(loc);
BlockStorage.clearBlockInfo(loc);

Slimefun.runSync(() -> {
loc.getBlock().setType(Material.LAVA);
loc.getWorld().createExplosion(loc, 0F, false);
});
provider.onExplode(loc);
} else {
supply = NumberUtils.flowSafeAddition(supply, energy);
}
Expand Down

0 comments on commit 51a1d1b

Please sign in to comment.