feat: make shield disable cooldown also a gamerule
This commit is contained in:
@@ -8,8 +8,13 @@ import net.minecraft.world.GameRules;
|
|||||||
public class Tweaks implements ModInitializer {
|
public class Tweaks implements ModInitializer {
|
||||||
public static final GameRules.Key<GameRules.IntRule> ENTITY_PORTAL_COOLDOWN =
|
public static final GameRules.Key<GameRules.IntRule> ENTITY_PORTAL_COOLDOWN =
|
||||||
GameRuleRegistry.register("entityPortalCooldown", GameRules.Category.MOBS, GameRuleFactory.createIntRule(300, 0, Integer.MAX_VALUE));
|
GameRuleRegistry.register("entityPortalCooldown", GameRules.Category.MOBS, GameRuleFactory.createIntRule(300, 0, Integer.MAX_VALUE));
|
||||||
|
|
||||||
public static final GameRules.Key<GameRules.IntRule> ENDER_PEARL_DAMAGE =
|
public static final GameRules.Key<GameRules.IntRule> ENDER_PEARL_DAMAGE =
|
||||||
GameRuleRegistry.register("enderPearlDamage", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(5, 0, Integer.MAX_VALUE));
|
GameRuleRegistry.register("enderPearlDamage", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(5, 0, Integer.MAX_VALUE));
|
||||||
|
|
||||||
|
public static final GameRules.Key<GameRules.IntRule> SHIELD_AXE_COOLDOWN =
|
||||||
|
GameRuleRegistry.register("shieldAxeCooldown", GameRules.Category.PLAYER, GameRuleFactory.createIntRule(100, 0, Integer.MAX_VALUE));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package systems.brn.tweaks.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.world.GameRules;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Constant;
|
||||||
|
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||||
|
import systems.brn.tweaks.Tweaks;
|
||||||
|
|
||||||
|
@Mixin(PlayerEntity.class)
|
||||||
|
public abstract class PlayerEntityMixin {
|
||||||
|
|
||||||
|
@ModifyConstant(
|
||||||
|
method = "disableShield(Lnet/minecraft/item/ItemStack;)V",
|
||||||
|
constant = @Constant(intValue = 100)
|
||||||
|
)
|
||||||
|
private int modifyShieldCooldownConstant(int original) {
|
||||||
|
PlayerEntity player = (PlayerEntity)(Object)this;
|
||||||
|
if (player.getWorld() != null && player.getWorld() instanceof ServerWorld sWorld) {
|
||||||
|
GameRules.IntRule rule = sWorld.getGameRules().get(Tweaks.SHIELD_AXE_COOLDOWN);
|
||||||
|
return rule.get();
|
||||||
|
}
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,8 @@
|
|||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"DontHurtMePearlMixin",
|
"DontHurtMePearlMixin",
|
||||||
"JustTeleportAlreadyMixin"
|
"JustTeleportAlreadyMixin",
|
||||||
|
"PlayerEntityMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|||||||
Reference in New Issue
Block a user