feat: add leash distance gamerules

This commit is contained in:
2025-12-03 04:14:36 +01:00
parent 75fed26c3c
commit c82c5f911f
2 changed files with 38 additions and 0 deletions

View File

@@ -30,6 +30,12 @@ public class Tweaks implements ModInitializer {
public static final GameRules.Key<GameRules.IntRule> ENDER_EYE_POP_CHANCE =
GameRuleRegistry.register("enderEyePopChance", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(20, 0, 100));
public static final GameRules.Key<GameRules.IntRule> LEASH_BREAK_DISTANCE =
GameRuleRegistry.register("leashBreakDistance", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(10, 0, Integer.MAX_VALUE));
public static final GameRules.Key<GameRules.IntRule> LEASH_ELASTIC_DISTANCE =
GameRuleRegistry.register("leashElasticDistance", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(6, 0, Integer.MAX_VALUE));
@Override
public void onInitialize() {
}

View File

@@ -0,0 +1,32 @@
package systems.brn.tweaks.mixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.Leashable;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.GameRules;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import systems.brn.tweaks.Tweaks;
@Mixin(Leashable.class)
public interface LeashableMixin {
@ModifyConstant(
method = "tickLeash",
constant = @Constant(doubleValue = 10.0)
)
private static double modifyLeashBreakDistance(double original, ServerWorld world, Entity entity) {
GameRules.IntRule rule = world.getGameRules().get(Tweaks.LEASH_BREAK_DISTANCE);
return rule.get();
}
@ModifyConstant(
method = "tickLeash",
constant = @Constant(doubleValue = 6.0)
)
private static double modifyLeashElasticDistance(double original, ServerWorld world, Entity entity) {
GameRules.IntRule rule = world.getGameRules().get(Tweaks.LEASH_ELASTIC_DISTANCE);
return rule.get();
}
}