Skip to content

Commit a2a1863

Browse files
authored
Improve compatibility of some mixins (#154)
1 parent 84ca7b2 commit a2a1863

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ usesMixins = true
9191
separateMixinSourceSet =
9292

9393
# Adds some debug arguments like verbose output and class export.
94-
usesMixinDebug = false
94+
usesMixinDebug = true
9595

9696
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
9797
mixinPlugin =
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
package org.embeddedt.archaicfix.mixins.client.core;
22

3-
import net.minecraft.client.settings.GameSettings;
3+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
44
import net.minecraft.server.integrated.IntegratedServer;
55
import org.embeddedt.archaicfix.config.ArchaicConfig;
66
import org.objectweb.asm.Opcodes;
77
import org.spongepowered.asm.mixin.Mixin;
88
import org.spongepowered.asm.mixin.injection.At;
9-
import org.spongepowered.asm.mixin.injection.Redirect;
109

1110
@Mixin(IntegratedServer.class)
1211
public class MixinIntegratedServer {
1312
/**
1413
* Force the integrated server to have a minimum view distance of 8, so mob spawning works correctly.
1514
*/
16-
@Redirect(method = "tick", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/client/settings/GameSettings;renderDistanceChunks:I"))
17-
private int getRealRenderDistance(GameSettings settings) {
18-
if(ArchaicConfig.fixMobSpawnsAtLowRenderDist)
19-
return Math.max(settings.renderDistanceChunks, 8);
20-
else
21-
return settings.renderDistanceChunks;
15+
@ModifyExpressionValue(method = "tick", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/client/settings/GameSettings;renderDistanceChunks:I"))
16+
private int getRealRenderDistance(int original) {
17+
return ArchaicConfig.fixMobSpawnsAtLowRenderDist ? Math.max(original, 8) : original;
2218
}
2319
}

src/main/java/org/embeddedt/archaicfix/mixins/common/core/MixinSpawnerAnimals.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.embeddedt.archaicfix.mixins.common.core;
22

3+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
34
import net.minecraft.entity.Entity;
45
import net.minecraft.world.SpawnerAnimals;
56
import net.minecraft.world.World;
@@ -10,14 +11,14 @@
1011
@Mixin(SpawnerAnimals.class)
1112
public class MixinSpawnerAnimals {
1213

13-
@ModifyConstant(method = "findChunksForSpawning", constant = @Constant(doubleValue = 24.0D))
14+
@ModifyExpressionValue(method = "findChunksForSpawning", at = @At(value = "CONSTANT", args = "doubleValue=24.0"))
1415
private double lowerSpawnRange(double old) {
1516
return ArchaicConfig.fixMobSpawnsAtLowRenderDist ? 16 : old;
1617
}
1718

1819
@Redirect(method = "performWorldGenSpawning", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntityInWorld(Lnet/minecraft/entity/Entity;)Z"))
1920
private static boolean checkForCollision(World world, Entity instance) {
20-
if(!ArchaicConfig.preventEntitySuffocationWorldgen || world.getCollidingBoundingBoxes(instance, instance.boundingBox).isEmpty()) {
21+
if (!ArchaicConfig.preventEntitySuffocationWorldgen || world.getCollidingBoundingBoxes(instance, instance.boundingBox).isEmpty()) {
2122
return world.spawnEntityInWorld(instance);
2223
}
2324
return false;

0 commit comments

Comments
 (0)