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 3e55c659..dd4f0aa9 100644 --- a/fabric/src/main/java/ca/spottedleaf/moonrise/fabric/FabricHooks.java +++ b/fabric/src/main/java/ca/spottedleaf/moonrise/fabric/FabricHooks.java @@ -1,5 +1,6 @@ package ca.spottedleaf.moonrise.fabric; +import ca.spottedleaf.moonrise.common.util.BaseChunkSystemHooks; import ca.spottedleaf.moonrise.common.PlatformHooks; import ca.spottedleaf.moonrise.common.util.ConfigHolder; import com.mojang.datafixers.DSL; @@ -32,7 +33,7 @@ import java.util.List; import java.util.function.Predicate; -public final class FabricHooks implements PlatformHooks { +public final class FabricHooks extends BaseChunkSystemHooks implements PlatformHooks { private static final boolean HAS_FABRIC_LIFECYCLE_EVENTS = FabricLoader.getInstance().isModLoaded("fabric-lifecycle-events-v1"); diff --git a/neoforge/src/main/java/ca/spottedleaf/moonrise/neoforge/NeoForgeHooks.java b/neoforge/src/main/java/ca/spottedleaf/moonrise/neoforge/NeoForgeHooks.java index d1c32beb..36fab0f6 100644 --- a/neoforge/src/main/java/ca/spottedleaf/moonrise/neoforge/NeoForgeHooks.java +++ b/neoforge/src/main/java/ca/spottedleaf/moonrise/neoforge/NeoForgeHooks.java @@ -1,5 +1,6 @@ package ca.spottedleaf.moonrise.neoforge; +import ca.spottedleaf.moonrise.common.util.BaseChunkSystemHooks; import ca.spottedleaf.moonrise.common.PlatformHooks; import ca.spottedleaf.moonrise.common.util.ConfigHolder; import ca.spottedleaf.moonrise.common.util.CoordinateUtils; @@ -38,7 +39,7 @@ import java.util.List; import java.util.function.Predicate; -public final class NeoForgeHooks implements PlatformHooks { +public final class NeoForgeHooks extends BaseChunkSystemHooks implements PlatformHooks { @Override public String getBrand() { diff --git a/src/main/java/ca/spottedleaf/moonrise/common/PlatformHooks.java b/src/main/java/ca/spottedleaf/moonrise/common/PlatformHooks.java index 38226663..5721a87b 100644 --- a/src/main/java/ca/spottedleaf/moonrise/common/PlatformHooks.java +++ b/src/main/java/ca/spottedleaf/moonrise/common/PlatformHooks.java @@ -1,5 +1,6 @@ package ca.spottedleaf.moonrise.common; +import ca.spottedleaf.moonrise.common.util.ChunkSystemHooks; import com.mojang.datafixers.DSL; import com.mojang.datafixers.DataFixer; import net.minecraft.core.BlockPos; @@ -8,7 +9,6 @@ import net.minecraft.server.level.GenerationChunkHolder; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.util.datafix.DataFixTypes; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.ChunkPos; @@ -24,7 +24,7 @@ import java.util.ServiceLoader; import java.util.function.Predicate; -public interface PlatformHooks { +public interface PlatformHooks extends ChunkSystemHooks { public static PlatformHooks get() { return Holder.INSTANCE; } @@ -64,8 +64,6 @@ public void addToGetEntities(final Level world, final EntityT public void entityMove(final Entity entity, final long oldSection, final long newSection); - public boolean screenEntity(final ServerLevel world, final Entity entity, final boolean fromDisk, final boolean event); - public boolean configFixMC224294(); public boolean configAutoConfigSendDistance(); diff --git a/src/main/java/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java b/src/main/java/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java index e319619b..4ec6320c 100644 --- a/src/main/java/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java +++ b/src/main/java/ca/spottedleaf/moonrise/common/misc/NearbyPlayers.java @@ -1,9 +1,9 @@ package ca.spottedleaf.moonrise.common.misc; +import ca.spottedleaf.moonrise.common.PlatformHooks; import ca.spottedleaf.moonrise.common.list.ReferenceList; import ca.spottedleaf.moonrise.common.util.CoordinateUtils; import ca.spottedleaf.moonrise.common.util.MoonriseConstants; -import ca.spottedleaf.moonrise.common.util.ChunkSystem; import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel; import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData; import ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickConstants; @@ -121,8 +121,8 @@ public void tickPlayer(final ServerPlayer player) { players[NearbyMapType.GENERAL.ordinal()].update(chunk.x, chunk.z, GENERAL_AREA_VIEW_DISTANCE); players[NearbyMapType.GENERAL_SMALL.ordinal()].update(chunk.x, chunk.z, GENERAL_SMALL_VIEW_DISTANCE); players[NearbyMapType.GENERAL_REALLY_SMALL.ordinal()].update(chunk.x, chunk.z, GENERAL_REALLY_SMALL_VIEW_DISTANCE); - players[NearbyMapType.TICK_VIEW_DISTANCE.ordinal()].update(chunk.x, chunk.z, ChunkSystem.getTickViewDistance(player)); - players[NearbyMapType.VIEW_DISTANCE.ordinal()].update(chunk.x, chunk.z, ChunkSystem.getViewDistance(player)); + players[NearbyMapType.TICK_VIEW_DISTANCE.ordinal()].update(chunk.x, chunk.z, PlatformHooks.get().getTickViewDistance(player)); + players[NearbyMapType.VIEW_DISTANCE.ordinal()].update(chunk.x, chunk.z, PlatformHooks.get().getViewDistance(player)); players[NearbyMapType.SPAWN_RANGE.ordinal()].update(chunk.x, chunk.z, ChunkTickConstants.PLAYER_SPAWN_TRACK_RANGE); // Moonrise - chunk tick iteration } diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java b/src/main/java/ca/spottedleaf/moonrise/common/util/BaseChunkSystemHooks.java similarity index 51% rename from src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java rename to src/main/java/ca/spottedleaf/moonrise/common/util/BaseChunkSystemHooks.java index e73d5f19..b9636cb4 100644 --- a/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java +++ b/src/main/java/ca/spottedleaf/moonrise/common/util/BaseChunkSystemHooks.java @@ -1,121 +1,125 @@ package ca.spottedleaf.moonrise.common.util; import ca.spottedleaf.concurrentutil.util.Priority; -import ca.spottedleaf.moonrise.common.PlatformHooks; import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel; import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk; import ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader; import ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemServerChunkCache; import ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickServerLevel; -import com.mojang.logging.LogUtils; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.FullChunkStatus; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.progress.ChunkProgressListener; -import net.minecraft.world.entity.Entity; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.status.ChunkStatus; -import org.slf4j.Logger; import java.util.List; import java.util.function.Consumer; -public final class ChunkSystem { +public abstract class BaseChunkSystemHooks implements ChunkSystemHooks { - private static final Logger LOGGER = LogUtils.getLogger(); - - public static void scheduleChunkTask(final ServerLevel level, final int chunkX, final int chunkZ, final Runnable run) { + @Override + public void scheduleChunkTask(final ServerLevel level, final int chunkX, final int chunkZ, final Runnable run) { scheduleChunkTask(level, chunkX, chunkZ, run, Priority.NORMAL); } - public static void scheduleChunkTask(final ServerLevel level, final int chunkX, final int chunkZ, final Runnable run, final Priority priority) { + @Override + public void scheduleChunkTask(final ServerLevel level, final int chunkX, final int chunkZ, final Runnable run, final Priority priority) { ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleChunkTask(chunkX, chunkZ, run, priority); } - public static void scheduleChunkLoad(final ServerLevel level, final int chunkX, final int chunkZ, final boolean gen, - final ChunkStatus toStatus, final boolean addTicket, final Priority priority, - final Consumer onComplete) { + @Override + public void scheduleChunkLoad(final ServerLevel level, final int chunkX, final int chunkZ, final boolean gen, + final ChunkStatus toStatus, final boolean addTicket, final Priority priority, + final Consumer onComplete) { ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleChunkLoad(chunkX, chunkZ, gen, toStatus, addTicket, priority, onComplete); } - public static void scheduleChunkLoad(final ServerLevel level, final int chunkX, final int chunkZ, final ChunkStatus toStatus, - final boolean addTicket, final Priority priority, final Consumer onComplete) { + @Override + public void scheduleChunkLoad(final ServerLevel level, final int chunkX, final int chunkZ, final ChunkStatus toStatus, + final boolean addTicket, final Priority priority, final Consumer onComplete) { ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleChunkLoad(chunkX, chunkZ, toStatus, addTicket, priority, onComplete); } - public static void scheduleTickingState(final ServerLevel level, final int chunkX, final int chunkZ, - final FullChunkStatus toStatus, final boolean addTicket, - final Priority priority, final Consumer onComplete) { + @Override + public void scheduleTickingState(final ServerLevel level, final int chunkX, final int chunkZ, + final FullChunkStatus toStatus, final boolean addTicket, + final Priority priority, final Consumer onComplete) { ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleTickingState(chunkX, chunkZ, toStatus, addTicket, priority, onComplete); } - public static List getVisibleChunkHolders(final ServerLevel level) { + @Override + public List getVisibleChunkHolders(final ServerLevel level) { return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.getOldChunkHolders(); } - public static List getUpdatingChunkHolders(final ServerLevel level) { + @Override + public List getUpdatingChunkHolders(final ServerLevel level) { return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.getOldChunkHolders(); } - public static int getVisibleChunkHolderCount(final ServerLevel level) { + @Override + public int getVisibleChunkHolderCount(final ServerLevel level) { return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.size(); } - public static int getUpdatingChunkHolderCount(final ServerLevel level) { + @Override + public int getUpdatingChunkHolderCount(final ServerLevel level) { return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.size(); } - public static boolean hasAnyChunkHolders(final ServerLevel level) { + @Override + public boolean hasAnyChunkHolders(final ServerLevel level) { return getUpdatingChunkHolderCount(level) != 0; } - public static boolean screenEntity(final ServerLevel level, final Entity entity, final boolean fromDisk, final boolean event) { - if (!PlatformHooks.get().screenEntity(level, entity, fromDisk, event)) { - return false; - } - return true; - } - - public static void onChunkHolderCreate(final ServerLevel level, final ChunkHolder holder) { + @Override + public void onChunkHolderCreate(final ServerLevel level, final ChunkHolder holder) { } - public static void onChunkHolderDelete(final ServerLevel level, final ChunkHolder holder) { + @Override + public void onChunkHolderDelete(final ServerLevel level, final ChunkHolder holder) { // Update progress listener for LevelLoadingScreen final ChunkProgressListener progressListener = level.getChunkSource().chunkMap.progressListener; if (progressListener != null) { - ChunkSystem.scheduleChunkTask(level, holder.getPos().x, holder.getPos().z, () -> { + this.scheduleChunkTask(level, holder.getPos().x, holder.getPos().z, () -> { progressListener.onStatusChange(holder.getPos(), null); }); } } - public static void onChunkPreBorder(final LevelChunk chunk, final ChunkHolder holder) { + @Override + public void onChunkPreBorder(final LevelChunk chunk, final ChunkHolder holder) { ((ChunkSystemServerChunkCache)((ServerLevel)chunk.getLevel()).getChunkSource()) - .moonrise$setFullChunk(chunk.getPos().x, chunk.getPos().z, chunk); + .moonrise$setFullChunk(chunk.getPos().x, chunk.getPos().z, chunk); } - public static void onChunkBorder(final LevelChunk chunk, final ChunkHolder holder) { + @Override + public void onChunkBorder(final LevelChunk chunk, final ChunkHolder holder) { ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getLoadedChunks().add( - ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() + ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() ); } - public static void onChunkNotBorder(final LevelChunk chunk, final ChunkHolder holder) { + @Override + public void onChunkNotBorder(final LevelChunk chunk, final ChunkHolder holder) { ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getLoadedChunks().remove( - ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() + ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() ); } - public static void onChunkPostNotBorder(final LevelChunk chunk, final ChunkHolder holder) { + @Override + public void onChunkPostNotBorder(final LevelChunk chunk, final ChunkHolder holder) { ((ChunkSystemServerChunkCache)((ServerLevel)chunk.getLevel()).getChunkSource()) - .moonrise$setFullChunk(chunk.getPos().x, chunk.getPos().z, null); + .moonrise$setFullChunk(chunk.getPos().x, chunk.getPos().z, null); } - public static void onChunkTicking(final LevelChunk chunk, final ChunkHolder holder) { + @Override + public void onChunkTicking(final LevelChunk chunk, final ChunkHolder holder) { ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getTickingChunks().add( - ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() + ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() ); if (!((ChunkSystemLevelChunk)chunk).moonrise$isPostProcessingDone()) { chunk.postProcessGeneration((ServerLevel)chunk.getLevel()); @@ -125,52 +129,60 @@ public static void onChunkTicking(final LevelChunk chunk, final ChunkHolder hold ((ChunkTickServerLevel)(ServerLevel)chunk.getLevel()).moonrise$markChunkForPlayerTicking(chunk); // Moonrise - chunk tick iteration } - public static void onChunkNotTicking(final LevelChunk chunk, final ChunkHolder holder) { + @Override + public void onChunkNotTicking(final LevelChunk chunk, final ChunkHolder holder) { ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getTickingChunks().remove( - ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() + ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() ); ((ChunkTickServerLevel)(ServerLevel)chunk.getLevel()).moonrise$removeChunkForPlayerTicking(chunk); // Moonrise - chunk tick iteration } - public static void onChunkEntityTicking(final LevelChunk chunk, final ChunkHolder holder) { + @Override + public void onChunkEntityTicking(final LevelChunk chunk, final ChunkHolder holder) { ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getEntityTickingChunks().add( - ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() + ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() ); } - public static void onChunkNotEntityTicking(final LevelChunk chunk, final ChunkHolder holder) { + @Override + public void onChunkNotEntityTicking(final LevelChunk chunk, final ChunkHolder holder) { ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getEntityTickingChunks().remove( - ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() + ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() ); } - public static ChunkHolder getUnloadingChunkHolder(final ServerLevel level, final int chunkX, final int chunkZ) { + @Override + public ChunkHolder getUnloadingChunkHolder(final ServerLevel level, final int chunkX, final int chunkZ) { return null; } - public static int getSendViewDistance(final ServerPlayer player) { + @Override + public int getSendViewDistance(final ServerPlayer player) { return RegionizedPlayerChunkLoader.getAPISendViewDistance(player); } - public static int getViewDistance(final ServerPlayer player) { + @Override + public int getViewDistance(final ServerPlayer player) { return RegionizedPlayerChunkLoader.getAPIViewDistance(player); } - public static int getTickViewDistance(final ServerPlayer player) { + @Override + public int getTickViewDistance(final ServerPlayer player) { return RegionizedPlayerChunkLoader.getAPITickViewDistance(player); } - public static void addPlayerToDistanceMaps(final ServerLevel world, final ServerPlayer player) { + @Override + public void addPlayerToDistanceMaps(final ServerLevel world, final ServerPlayer player) { ((ChunkSystemServerLevel)world).moonrise$getPlayerChunkLoader().addPlayer(player); } - public static void removePlayerFromDistanceMaps(final ServerLevel world, final ServerPlayer player) { + @Override + public void removePlayerFromDistanceMaps(final ServerLevel world, final ServerPlayer player) { ((ChunkSystemServerLevel)world).moonrise$getPlayerChunkLoader().removePlayer(player); } - public static void updateMaps(final ServerLevel world, final ServerPlayer player) { + @Override + public void updateMaps(final ServerLevel world, final ServerPlayer player) { ((ChunkSystemServerLevel)world).moonrise$getPlayerChunkLoader().updatePlayer(player); } - - private ChunkSystem() {} } diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystemHooks.java b/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystemHooks.java new file mode 100644 index 00000000..427079ae --- /dev/null +++ b/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystemHooks.java @@ -0,0 +1,77 @@ +package ca.spottedleaf.moonrise.common.util; + +import ca.spottedleaf.concurrentutil.util.Priority; +import net.minecraft.server.level.ChunkHolder; +import net.minecraft.server.level.FullChunkStatus; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.status.ChunkStatus; +import java.util.List; +import java.util.function.Consumer; + +public interface ChunkSystemHooks { + + public void scheduleChunkTask(final ServerLevel level, final int chunkX, final int chunkZ, final Runnable run); + + public void scheduleChunkTask(final ServerLevel level, final int chunkX, final int chunkZ, final Runnable run, final Priority priority); + + public void scheduleChunkLoad(final ServerLevel level, final int chunkX, final int chunkZ, final boolean gen, + final ChunkStatus toStatus, final boolean addTicket, final Priority priority, + final Consumer onComplete); + + public void scheduleChunkLoad(final ServerLevel level, final int chunkX, final int chunkZ, final ChunkStatus toStatus, + final boolean addTicket, final Priority priority, final Consumer onComplete); + + public void scheduleTickingState(final ServerLevel level, final int chunkX, final int chunkZ, + final FullChunkStatus toStatus, final boolean addTicket, + final Priority priority, final Consumer onComplete); + + public List getVisibleChunkHolders(final ServerLevel level); + + public List getUpdatingChunkHolders(final ServerLevel level); + + public int getVisibleChunkHolderCount(final ServerLevel level); + + public int getUpdatingChunkHolderCount(final ServerLevel level); + + public boolean hasAnyChunkHolders(final ServerLevel level); + + public boolean screenEntity(final ServerLevel level, final Entity entity, final boolean fromDisk, final boolean event); + + public void onChunkHolderCreate(final ServerLevel level, final ChunkHolder holder); + + public void onChunkHolderDelete(final ServerLevel level, final ChunkHolder holder); + + public void onChunkPreBorder(final LevelChunk chunk, final ChunkHolder holder); + + public void onChunkBorder(final LevelChunk chunk, final ChunkHolder holder); + + public void onChunkNotBorder(final LevelChunk chunk, final ChunkHolder holder); + + public void onChunkPostNotBorder(final LevelChunk chunk, final ChunkHolder holder); + + public void onChunkTicking(final LevelChunk chunk, final ChunkHolder holder); + + public void onChunkNotTicking(final LevelChunk chunk, final ChunkHolder holder); + + public void onChunkEntityTicking(final LevelChunk chunk, final ChunkHolder holder); + + public void onChunkNotEntityTicking(final LevelChunk chunk, final ChunkHolder holder); + + public ChunkHolder getUnloadingChunkHolder(final ServerLevel level, final int chunkX, final int chunkZ); + + public int getSendViewDistance(final ServerPlayer player); + + public int getViewDistance(final ServerPlayer player); + + public int getTickViewDistance(final ServerPlayer player); + + public void addPlayerToDistanceMaps(final ServerLevel world, final ServerPlayer player); + + public void removePlayerFromDistanceMaps(final ServerLevel world, final ServerPlayer player); + + public void updateMaps(final ServerLevel world, final ServerPlayer player); +} diff --git a/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/ChunkMapMixin.java b/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/ChunkMapMixin.java index f55cc867..f86cbf58 100644 --- a/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/ChunkMapMixin.java +++ b/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/ChunkMapMixin.java @@ -1,7 +1,7 @@ package ca.spottedleaf.moonrise.mixin.chunk_system; +import ca.spottedleaf.moonrise.common.PlatformHooks; import ca.spottedleaf.moonrise.common.util.MoonriseConstants; -import ca.spottedleaf.moonrise.common.util.ChunkSystem; import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO; import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemChunkMap; import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel; @@ -499,7 +499,7 @@ public void setServerViewDistance(final int watchDistance) { */ @Overwrite public int getPlayerViewDistance(final ServerPlayer player) { - return ChunkSystem.getSendViewDistance(player); + return PlatformHooks.get().getSendViewDistance(player); } /** @@ -597,7 +597,7 @@ public void flushWorker() { ) ) private void avoidUpdateChunkTrackingInUpdate(final ChunkMap instance, final ServerPlayer serverPlayer) { - ChunkSystem.addPlayerToDistanceMaps(this.level, serverPlayer); + PlatformHooks.get().addPlayerToDistanceMaps(this.level, serverPlayer); } /** @@ -627,7 +627,7 @@ private void skipChunkTrackingInTick(final ChunkMap instance, final ServerPlayer ) private void avoidApplyChunkTrackingViewInUpdate(final ChunkMap instance, final ServerPlayer serverPlayer, final ChunkTrackingView chunkTrackingView) { - ChunkSystem.removePlayerFromDistanceMaps(this.level, serverPlayer); + PlatformHooks.get().removePlayerFromDistanceMaps(this.level, serverPlayer); } /** @@ -641,7 +641,7 @@ private void avoidApplyChunkTrackingViewInUpdate(final ChunkMap instance, final ) ) private void updateMapsHook(final ServerPlayer player, final CallbackInfo ci) { - ChunkSystem.updateMaps(this.level, player); + PlatformHooks.get().updateMaps(this.level, player); } /** diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java index 58d9187a..26207443 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/server/ServerEntityLookup.java @@ -4,7 +4,6 @@ import ca.spottedleaf.moonrise.common.list.ReferenceList; import ca.spottedleaf.moonrise.common.util.CoordinateUtils; import ca.spottedleaf.moonrise.common.util.TickThread; -import ca.spottedleaf.moonrise.common.util.ChunkSystem; import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel; import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices; import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup; @@ -111,6 +110,6 @@ protected void entityEndTicking(final Entity entity) { @Override protected boolean screenEntity(final Entity entity, final boolean fromDisk, final boolean event) { - return ChunkSystem.screenEntity(this.serverWorld, entity, fromDisk, event); + return PlatformHooks.get().screenEntity(this.serverWorld, entity, fromDisk, event); } } diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java index bc4f2714..e4ff3552 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java @@ -7,7 +7,6 @@ import ca.spottedleaf.moonrise.common.util.CoordinateUtils; import ca.spottedleaf.moonrise.common.util.TickThread; import ca.spottedleaf.moonrise.common.util.WorldUtil; -import ca.spottedleaf.moonrise.common.util.ChunkSystem; import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO; import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel; import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices; @@ -818,7 +817,7 @@ public void lowerPriority(final int x, final int z, final Priority priority) { private NewChunkHolder createChunkHolder(final long position) { final NewChunkHolder ret = new NewChunkHolder(this.world, CoordinateUtils.getChunkX(position), CoordinateUtils.getChunkZ(position), this.taskScheduler); - ChunkSystem.onChunkHolderCreate(this.world, ret.vanillaChunkHolder); + PlatformHooks.get().onChunkHolderCreate(this.world, ret.vanillaChunkHolder); return ret; } @@ -1026,7 +1025,7 @@ void addChangedStatuses(final List changedFullStatus) { private void removeChunkHolder(final NewChunkHolder holder) { holder.onUnload(); this.autoSaveQueue.remove(holder); - ChunkSystem.onChunkHolderDelete(this.world, holder.vanillaChunkHolder); + PlatformHooks.get().onChunkHolderDelete(this.world, holder.vanillaChunkHolder); this.chunkHolders.remove(CoordinateUtils.getChunkKey(holder.chunkX, holder.chunkZ)); } diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java index eafa4e6d..e4a5fa25 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java @@ -11,7 +11,6 @@ import ca.spottedleaf.moonrise.common.util.CoordinateUtils; import ca.spottedleaf.moonrise.common.util.TickThread; import ca.spottedleaf.moonrise.common.util.WorldUtil; -import ca.spottedleaf.moonrise.common.util.ChunkSystem; import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData; import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO; import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel; @@ -1270,10 +1269,10 @@ public boolean handleFullStatusChange(final List changedFullStat // state upgrade if (!current.isOrAfter(FullChunkStatus.FULL) && pending.isOrAfter(FullChunkStatus.FULL)) { this.updateCurrentState(FullChunkStatus.FULL); - ChunkSystem.onChunkPreBorder(chunk, this.vanillaChunkHolder); + PlatformHooks.get().onChunkPreBorder(chunk, this.vanillaChunkHolder); this.scheduler.chunkHolderManager.ensureInAutosave(this); this.changeEntityChunkStatus(FullChunkStatus.FULL); - ChunkSystem.onChunkBorder(chunk, this.vanillaChunkHolder); + PlatformHooks.get().onChunkBorder(chunk, this.vanillaChunkHolder); this.onFullChunkLoadChange(true, changedFullStatus); this.completeFullStatusConsumers(FullChunkStatus.FULL, chunk); } @@ -1281,34 +1280,34 @@ public boolean handleFullStatusChange(final List changedFullStat if (!current.isOrAfter(FullChunkStatus.BLOCK_TICKING) && pending.isOrAfter(FullChunkStatus.BLOCK_TICKING)) { this.updateCurrentState(FullChunkStatus.BLOCK_TICKING); this.changeEntityChunkStatus(FullChunkStatus.BLOCK_TICKING); - ChunkSystem.onChunkTicking(chunk, this.vanillaChunkHolder); + PlatformHooks.get().onChunkTicking(chunk, this.vanillaChunkHolder); this.completeFullStatusConsumers(FullChunkStatus.BLOCK_TICKING, chunk); } if (!current.isOrAfter(FullChunkStatus.ENTITY_TICKING) && pending.isOrAfter(FullChunkStatus.ENTITY_TICKING)) { this.updateCurrentState(FullChunkStatus.ENTITY_TICKING); this.changeEntityChunkStatus(FullChunkStatus.ENTITY_TICKING); - ChunkSystem.onChunkEntityTicking(chunk, this.vanillaChunkHolder); + PlatformHooks.get().onChunkEntityTicking(chunk, this.vanillaChunkHolder); this.completeFullStatusConsumers(FullChunkStatus.ENTITY_TICKING, chunk); } } else { if (current.isOrAfter(FullChunkStatus.ENTITY_TICKING) && !pending.isOrAfter(FullChunkStatus.ENTITY_TICKING)) { this.changeEntityChunkStatus(FullChunkStatus.BLOCK_TICKING); - ChunkSystem.onChunkNotEntityTicking(chunk, this.vanillaChunkHolder); + PlatformHooks.get().onChunkNotEntityTicking(chunk, this.vanillaChunkHolder); this.updateCurrentState(FullChunkStatus.BLOCK_TICKING); } if (current.isOrAfter(FullChunkStatus.BLOCK_TICKING) && !pending.isOrAfter(FullChunkStatus.BLOCK_TICKING)) { this.changeEntityChunkStatus(FullChunkStatus.FULL); - ChunkSystem.onChunkNotTicking(chunk, this.vanillaChunkHolder); + PlatformHooks.get().onChunkNotTicking(chunk, this.vanillaChunkHolder); this.updateCurrentState(FullChunkStatus.FULL); } if (current.isOrAfter(FullChunkStatus.FULL) && !pending.isOrAfter(FullChunkStatus.FULL)) { this.onFullChunkLoadChange(false, changedFullStatus); this.changeEntityChunkStatus(FullChunkStatus.INACCESSIBLE); - ChunkSystem.onChunkNotBorder(chunk, this.vanillaChunkHolder); - ChunkSystem.onChunkPostNotBorder(chunk, this.vanillaChunkHolder); + PlatformHooks.get().onChunkNotBorder(chunk, this.vanillaChunkHolder); + PlatformHooks.get().onChunkPostNotBorder(chunk, this.vanillaChunkHolder); this.updateCurrentState(FullChunkStatus.INACCESSIBLE); } }