forked from BRNSystems/tweaks
feat: add leash distance gamerules
This commit is contained in:
@@ -30,6 +30,12 @@ public class Tweaks implements ModInitializer {
|
|||||||
public static final GameRules.Key<GameRules.IntRule> ENDER_EYE_POP_CHANCE =
|
public static final GameRules.Key<GameRules.IntRule> ENDER_EYE_POP_CHANCE =
|
||||||
GameRuleRegistry.register("enderEyePopChance", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(20, 0, 100));
|
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
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/main/java/systems/brn/tweaks/mixin/LeashableMixin.java
Normal file
32
src/main/java/systems/brn/tweaks/mixin/LeashableMixin.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user