diff --git a/fabric/build.gradle b/fabric/build.gradle index dd01e80d..417dbbf8 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -24,7 +24,7 @@ dependencies { include "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}" modImplementation "com.terraformersmc:modmenu:11.0.1" - modImplementation fabricApiLibs.command.api.v2 + modImplementation fabricApiLibs.fabric.api include fabricApiLibs.command.api.v2 include fabricApiLibs.base } diff --git a/fabric/src/main/java/ca/spottedleaf/moonrise/fabric/FabricHooks.java b/fabric/src/main/java/ca/spottedleaf/moonrise/fabric/FabricHooks.java index fa6c818d..cfd0ef5a 100644 --- a/fabric/src/main/java/ca/spottedleaf/moonrise/fabric/FabricHooks.java +++ b/fabric/src/main/java/ca/spottedleaf/moonrise/fabric/FabricHooks.java @@ -3,6 +3,9 @@ import ca.spottedleaf.moonrise.common.PlatformHooks; import ca.spottedleaf.moonrise.common.util.ConfigHolder; import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder; +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.GenerationChunkHolder; @@ -25,6 +28,19 @@ public final class FabricHooks implements PlatformHooks { + public interface OnExplosionDetonate { + void onExplosion(final Level world, final Explosion explosion, final List possiblyAffecting, final double diameter); + } + + public static final Event ON_EXPLOSION = EventFactory.createArrayBacked( + OnExplosionDetonate.class, + listeners -> (final Level world, final Explosion explosion, final List possiblyAffecting, final double diameter) -> { + for (int i = 0; i < listeners.length; i++) { + listeners[i].onExplosion(world, explosion, possiblyAffecting, diameter); + } + } + ); + @Override public String getBrand() { return "Moonrise"; @@ -44,7 +60,7 @@ public Predicate maybeHasLightEmission() { @Override public void onExplosion(final Level world, final Explosion explosion, final List possiblyAffecting, final double diameter) { - + ON_EXPLOSION.invoker().onExplosion(world, explosion, possiblyAffecting, diameter); } @Override @@ -69,7 +85,7 @@ public void setCurrentlyLoading(final GenerationChunkHolder holder, final LevelC @Override public void chunkFullStatusComplete(final LevelChunk newChunk, final ProtoChunk original) { - + ServerChunkEvents.CHUNK_LOAD.invoker().onChunkLoad((ServerLevel) newChunk.getLevel(), newChunk); } @Override @@ -84,7 +100,7 @@ public void onChunkHolderTicketChange(final ServerLevel world, final NewChunkHol @Override public void chunkUnloadFromWorld(final LevelChunk chunk) { - + ServerChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload((ServerLevel) chunk.getLevel(), chunk); } @Override