Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: onExplode customization on EnergyNetProvider #4267

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading