Skip to content

Commit

Permalink
fix: disallow simulation distance above 32
Browse files Browse the repository at this point in the history
Fixes #287
  • Loading branch information
ishland committed Apr 27, 2024
1 parent ea2569c commit f8f954c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.ishland.c2me.base.mixin.access;

import net.minecraft.server.world.ChunkTicketManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(ChunkTicketManager.DistanceFromNearestPlayerTracker.class)
public interface IChunkTicketManagerDistanceFromNearestPlayerTracker {

@Accessor
int getMaxDistance();

}
1 change: 1 addition & 0 deletions c2me-base/src/main/resources/c2me-base.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"access.IChunkSection",
"access.IChunkTicket",
"access.IChunkTicketManager",
"access.IChunkTicketManagerDistanceFromNearestPlayerTracker",
"access.IChunkTicketManagerNearbyChunkTicketUpdater",
"access.IChunkTickScheduler",
"access.IMultiNoiseBiomeSource",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.ishland.c2me.notickvd.mixin;

import com.ishland.c2me.base.mixin.access.IChunkTicketManagerDistanceFromNearestPlayerTracker;
import net.minecraft.server.world.ChunkTicketManager;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(ChunkTicketManager.NearbyChunkTicketUpdater.class)
public abstract class MixinChunkTicketManagerNearbyChunkTicketUpdater {

@ModifyVariable(method = "setWatchDistance", at = @At("HEAD"), argsOnly = true)
private int clampViewDistance(int watchDistance) {
return MathHelper.clamp(watchDistance, 0, ((IChunkTicketManagerDistanceFromNearestPlayerTracker) this).getMaxDistance());
}

}
1 change: 1 addition & 0 deletions c2me-notickvd/src/main/resources/c2me-notickvd.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"mixins": [
"MixinChunkHolder",
"MixinChunkTicketManager",
"MixinChunkTicketManagerNearbyChunkTicketUpdater",
"MixinPlayerManager",
"MixinServerChunkManager",
"MixinThreadedAnvilChunkStorage",
Expand Down

3 comments on commit f8f954c

@Fisch37
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, using loading distance >32 is literally why I use C2ME. Feels kinda restrictive solving it that way.

That being said, I don't know the codebase so maybe this is the best solution

@ishland
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, using loading distance >32 is literally why I use C2ME. Feels kinda restrictive solving it that way.

That being said, I don't know the codebase so maybe this is the best solution

View distance extension is not affected in any way. They are two different things.

We have never supported simulation distances higher than 32 and some mods are attempting to set it higher than 32 causing breakage.

@Fisch37
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, I confused myself! Simulation Distance 32 would be insane, true. Then I don't have anything to worry about, thanks for developing such an awesome mod <3

Please sign in to comment.