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 de932d56..50ff8f1a 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 @@ -2,12 +2,14 @@ import ca.spottedleaf.moonrise.patches.chunk_system.player.ChunkSystemServerPlayer; 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 org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PlayerList.class) @@ -28,4 +30,17 @@ private void initRealPlayer(final Connection connection, final ServerPlayer serv ((ChunkSystemServerPlayer)serverPlayer).moonrise$setRealPlayer(true); } + /** + * @reason The RegionizedPlayerChunkLoader will handle the VD packet + * @author Spottedleaf + */ + @Redirect( + method = "setViewDistance", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/server/players/PlayerList;broadcastAll(Lnet/minecraft/network/protocol/Packet;)V" + ) + ) + private void doNotAdjustVD(final PlayerList instance, final Packet packet) {} + } diff --git a/src/main/java/ca/spottedleaf/moonrise/mixin/entity_tracker/TrackedEntityMixin.java b/src/main/java/ca/spottedleaf/moonrise/mixin/entity_tracker/TrackedEntityMixin.java index 3e91e597..9c6e8b19 100644 --- a/src/main/java/ca/spottedleaf/moonrise/mixin/entity_tracker/TrackedEntityMixin.java +++ b/src/main/java/ca/spottedleaf/moonrise/mixin/entity_tracker/TrackedEntityMixin.java @@ -4,6 +4,7 @@ import ca.spottedleaf.moonrise.common.misc.NearbyPlayers; import ca.spottedleaf.moonrise.common.util.TickThread; import ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerTrackedEntity; +import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerPlayerConnection; @@ -11,6 +12,8 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; import java.util.Set; @Mixin(ChunkMap.TrackedEntity.class) @@ -25,6 +28,20 @@ abstract class TrackedEntityMixin implements EntityTrackerTrackedEntity { @Shadow public abstract void removePlayer(ServerPlayer serverPlayer); + /** + * @reason ReferenceOpenHashSet is a better choice than a wrapped IdentityHashMap + * @author Spottedleaf + */ + @Redirect( + method = "", + at = @At( + value = "INVOKE", + target = "Lcom/google/common/collect/Sets;newIdentityHashSet()Ljava/util/Set;" + ) + ) + private Set useBetterIdentitySet() { + return new ReferenceOpenHashSet<>(); + } @Unique private long lastChunkUpdate = -1L;