gamerule for toggling player crits
This commit is contained in:
@@ -16,3 +16,6 @@ Controls how much damage elytras take when boosting with a firework
|
|||||||
|
|
||||||
### elytraDamageFromRiptideTrident
|
### elytraDamageFromRiptideTrident
|
||||||
Controls how much damage elytras take when boosting with a riptide trident
|
Controls how much damage elytras take when boosting with a riptide trident
|
||||||
|
|
||||||
|
### playerCrits
|
||||||
|
Decides if players should be able to crit
|
||||||
@@ -12,6 +12,8 @@ public class ExtraGameRule {
|
|||||||
public static GameRules.Key<GameRules.IntRule> ELYTRA_DAMAGE_FROM_FIREWORK_BOOST;
|
public static GameRules.Key<GameRules.IntRule> ELYTRA_DAMAGE_FROM_FIREWORK_BOOST;
|
||||||
public static GameRules.Key<GameRules.IntRule> ELYTRA_DAMAGE_FROM_RIPTIDE_BOOST;
|
public static GameRules.Key<GameRules.IntRule> ELYTRA_DAMAGE_FROM_RIPTIDE_BOOST;
|
||||||
|
|
||||||
|
public static GameRules.Key<GameRules.BooleanRule> PLAYER_CRITS;
|
||||||
|
|
||||||
protected static void init() {
|
protected static void init() {
|
||||||
MAGMA_BLOCK_DAMAGE = GameRuleRegistry.register(
|
MAGMA_BLOCK_DAMAGE = GameRuleRegistry.register(
|
||||||
"magmaBlockDamage",
|
"magmaBlockDamage",
|
||||||
@@ -38,6 +40,11 @@ public class ExtraGameRule {
|
|||||||
GameRules.Category.MISC,
|
GameRules.Category.MISC,
|
||||||
GameRuleFactory.createIntRule(0, 0, Integer.MAX_VALUE)
|
GameRuleFactory.createIntRule(0, 0, Integer.MAX_VALUE)
|
||||||
);
|
);
|
||||||
|
PLAYER_CRITS = GameRuleRegistry.register(
|
||||||
|
"playerCrits",
|
||||||
|
GameRules.Category.PLAYER,
|
||||||
|
GameRuleFactory.createBooleanRule(true)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package me.youhavetrouble.moregamerules.mixin;
|
||||||
|
|
||||||
|
import me.youhavetrouble.moregamerules.ExtraGameRule;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(PlayerEntity.class)
|
||||||
|
public class PlayerEntityMixin {
|
||||||
|
|
||||||
|
@Redirect(method = "attack", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerEntity;fallDistance:F", opcode = Opcodes.GETFIELD))
|
||||||
|
private float injected(PlayerEntity instance) {
|
||||||
|
if (instance.world.getGameRules().getBoolean(ExtraGameRule.PLAYER_CRITS)) {
|
||||||
|
return instance.fallDistance;
|
||||||
|
}
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,5 +8,7 @@
|
|||||||
"gamerule.elytraDamageFromFirework": "Elytra damage from firework boost",
|
"gamerule.elytraDamageFromFirework": "Elytra damage from firework boost",
|
||||||
"gamerule.elytraDamageFromFirework.description": "Controls how much damage elytras take when boosting with a firework",
|
"gamerule.elytraDamageFromFirework.description": "Controls how much damage elytras take when boosting with a firework",
|
||||||
"gamerule.elytraDamageFromRiptideTrident": "Elytra damage from firework boost",
|
"gamerule.elytraDamageFromRiptideTrident": "Elytra damage from firework boost",
|
||||||
"gamerule.elytraDamageFromRiptideTrident.description": "Controls how much damage elytras take when boosting with a riptide trident"
|
"gamerule.elytraDamageFromRiptideTrident.description": "Controls how much damage elytras take when boosting with a riptide trident",
|
||||||
|
"gamerule.playerCrits": "Player crits",
|
||||||
|
"gamerule.playerCrits.description": "Decides if players should be able to crit"
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
"mixins": [
|
"mixins": [
|
||||||
"FireworkItemMixin",
|
"FireworkItemMixin",
|
||||||
"LivingEntityMixin",
|
"LivingEntityMixin",
|
||||||
|
"PlayerEntityMixin",
|
||||||
"ServerWorldMixin",
|
"ServerWorldMixin",
|
||||||
"TridentItemMixin"
|
"TridentItemMixin"
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user