forked from BRNSystems/tweaks
feat: make crit damage multiplier a gamerule
This commit is contained in:
@@ -15,6 +15,9 @@ public class Tweaks implements ModInitializer {
|
||||
public static final GameRules.Key<GameRules.IntRule> SHIELD_AXE_COOLDOWN =
|
||||
GameRuleRegistry.register("shieldAxeCooldown", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(100, 0, Integer.MAX_VALUE));
|
||||
|
||||
public static final GameRules.Key<GameRules.IntRule> CRITICAL_MULTIPLIER =
|
||||
GameRuleRegistry.register("criticalHitMultiplier", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(150, 0, Integer.MAX_VALUE));
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
}
|
||||
|
||||
@@ -26,4 +26,17 @@ public abstract class PlayerEntityMixin {
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
@ModifyConstant(
|
||||
method = "attack",
|
||||
constant = @Constant(floatValue = 1.5F)
|
||||
)
|
||||
private float modifyCriticalMultiplier(float original) {
|
||||
PlayerEntity player = (PlayerEntity)(Object)this;
|
||||
if (player.getWorld() != null && player.getWorld() instanceof ServerWorld serverWorld) {
|
||||
GameRules.IntRule rule = serverWorld.getGameRules().get(Tweaks.CRITICAL_MULTIPLIER);
|
||||
return rule.get() / 100.0F;
|
||||
}
|
||||
return original;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user