diff --git a/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/PlayerListMixin.java b/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/PlayerListMixin.java index 50ff8f1a..e26b1de7 100644 --- a/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/PlayerListMixin.java +++ b/src/main/java/ca/spottedleaf/moonrise/mixin/chunk_system/PlayerListMixin.java @@ -1,11 +1,14 @@ package ca.spottedleaf.moonrise.mixin.chunk_system; +import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel; import ca.spottedleaf.moonrise.patches.chunk_system.player.ChunkSystemServerPlayer; +import ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader; import net.minecraft.network.Connection; import net.minecraft.network.protocol.Packet; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.CommonListenerCookie; import net.minecraft.server.players.PlayerList; +import net.minecraft.util.Unit; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -30,6 +33,26 @@ private void initRealPlayer(final Connection connection, final ServerPlayer serv ((ChunkSystemServerPlayer)serverPlayer).moonrise$setRealPlayer(true); } + /** + * @reason prevent chunk load cycling on join + * @author jpenilla + */ + @Inject( + method = "placeNewPlayer", + at = @At( + target = "Lnet/minecraft/server/level/ServerLevel;addNewPlayer(Lnet/minecraft/server/level/ServerPlayer;)V", + value = "INVOKE" + ) + ) + private void addJoinTicket(final Connection connection, final ServerPlayer serverPlayer, + final CommonListenerCookie commonListenerCookie, final CallbackInfo ci) { + ((ChunkSystemServerLevel) serverPlayer.serverLevel()).moonrise$getChunkTaskScheduler().chunkHolderManager.addTicketAtLevel( + RegionizedPlayerChunkLoader.PLAYER_JOIN, + serverPlayer.chunkPosition(), + RegionizedPlayerChunkLoader.TICK_TICKET_LEVEL, + Unit.INSTANCE); + } + /** * @reason The RegionizedPlayerChunkLoader will handle the VD packet * @author Spottedleaf diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java index e4282957..aaa86b51 100644 --- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java @@ -34,6 +34,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.TicketType; import net.minecraft.server.network.PlayerChunkSender; +import net.minecraft.util.Unit; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.GameRules; import net.minecraft.world.level.chunk.ChunkAccess; @@ -52,6 +53,7 @@ public final class RegionizedPlayerChunkLoader { public static final TicketType PLAYER_TICKET = TicketType.create("chunk_system:player_ticket", Long::compareTo); public static final TicketType PLAYER_TICKET_DELAYED = TicketType.create("chunk_system:player_ticket_delayed", Long::compareTo, 5 * 20); + public static final TicketType PLAYER_JOIN = TicketType.create("chunk_system:player_join", (a, b) -> 0, 5 * 20); public static final int MIN_VIEW_DISTANCE = 2; public static final int MAX_VIEW_DISTANCE = 32;