|
|
|
@@ -6,6 +6,7 @@ import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
|
|
|
|
import net.fabricmc.fabric.api.event.Event;
|
|
|
|
import net.fabricmc.fabric.api.event.Event;
|
|
|
|
import net.fabricmc.fabric.api.event.EventFactory;
|
|
|
|
import net.fabricmc.fabric.api.event.EventFactory;
|
|
|
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
|
|
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
|
|
|
|
|
|
|
import net.fabricmc.loader.api.FabricLoader;
|
|
|
|
import net.minecraft.core.BlockPos;
|
|
|
|
import net.minecraft.core.BlockPos;
|
|
|
|
import net.minecraft.nbt.CompoundTag;
|
|
|
|
import net.minecraft.nbt.CompoundTag;
|
|
|
|
import net.minecraft.server.level.GenerationChunkHolder;
|
|
|
|
import net.minecraft.server.level.GenerationChunkHolder;
|
|
|
|
@@ -18,6 +19,7 @@ import net.minecraft.world.level.Explosion;
|
|
|
|
import net.minecraft.world.level.Level;
|
|
|
|
import net.minecraft.world.level.Level;
|
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
|
|
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
|
|
|
|
|
|
|
import net.minecraft.world.level.chunk.ImposterProtoChunk;
|
|
|
|
import net.minecraft.world.level.chunk.LevelChunk;
|
|
|
|
import net.minecraft.world.level.chunk.LevelChunk;
|
|
|
|
import net.minecraft.world.level.chunk.ProtoChunk;
|
|
|
|
import net.minecraft.world.level.chunk.ProtoChunk;
|
|
|
|
import net.minecraft.world.level.entity.EntityTypeTest;
|
|
|
|
import net.minecraft.world.level.entity.EntityTypeTest;
|
|
|
|
@@ -28,6 +30,8 @@ import java.util.function.Predicate;
|
|
|
|
|
|
|
|
|
|
|
|
public final class FabricHooks implements PlatformHooks {
|
|
|
|
public final class FabricHooks implements PlatformHooks {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final boolean HAS_FABRIC_LIFECYCLE_EVENTS = FabricLoader.getInstance().isModLoaded("fabric-lifecycle-events-v1");
|
|
|
|
|
|
|
|
|
|
|
|
public interface OnExplosionDetonate {
|
|
|
|
public interface OnExplosionDetonate {
|
|
|
|
void onExplosion(final Level world, final Explosion explosion, final List<Entity> possiblyAffecting, final double diameter);
|
|
|
|
void onExplosion(final Level world, final Explosion explosion, final List<Entity> possiblyAffecting, final double diameter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -85,7 +89,12 @@ public final class FabricHooks implements PlatformHooks {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void chunkFullStatusComplete(final LevelChunk newChunk, final ProtoChunk original) {
|
|
|
|
public void chunkFullStatusComplete(final LevelChunk newChunk, final ProtoChunk original) {
|
|
|
|
|
|
|
|
if (HAS_FABRIC_LIFECYCLE_EVENTS) {
|
|
|
|
ServerChunkEvents.CHUNK_LOAD.invoker().onChunkLoad((ServerLevel) newChunk.getLevel(), newChunk);
|
|
|
|
ServerChunkEvents.CHUNK_LOAD.invoker().onChunkLoad((ServerLevel) newChunk.getLevel(), newChunk);
|
|
|
|
|
|
|
|
if (!(original instanceof ImposterProtoChunk)) {
|
|
|
|
|
|
|
|
ServerChunkEvents.CHUNK_GENERATE.invoker().onChunkGenerate((ServerLevel)newChunk.getLevel(), newChunk);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@@ -100,8 +109,10 @@ public final class FabricHooks implements PlatformHooks {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void chunkUnloadFromWorld(final LevelChunk chunk) {
|
|
|
|
public void chunkUnloadFromWorld(final LevelChunk chunk) {
|
|
|
|
|
|
|
|
if (HAS_FABRIC_LIFECYCLE_EVENTS) {
|
|
|
|
ServerChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload((ServerLevel) chunk.getLevel(), chunk);
|
|
|
|
ServerChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload((ServerLevel) chunk.getLevel(), chunk);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void chunkSyncSave(final ServerLevel world, final ChunkAccess chunk, final CompoundTag data) {
|
|
|
|
public void chunkSyncSave(final ServerLevel world, final ChunkAccess chunk, final CompoundTag data) {
|
|
|
|
|