add piston push limit
This commit is contained in:
@@ -11,8 +11,8 @@ public class ExtraGameRule {
|
||||
public static GameRules.Key<GameRules.IntRule> ELYTRA_DAMAGE_PER_SECOND;
|
||||
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.BooleanRule> PLAYER_CRITS;
|
||||
public static GameRules.Key<GameRules.IntRule> PISTON_PUSH_LIMIT;
|
||||
|
||||
protected static void init() {
|
||||
MAGMA_BLOCK_DAMAGE = GameRuleRegistry.register(
|
||||
@@ -45,6 +45,11 @@ public class ExtraGameRule {
|
||||
GameRules.Category.PLAYER,
|
||||
GameRuleFactory.createBooleanRule(true)
|
||||
);
|
||||
PISTON_PUSH_LIMIT = GameRuleRegistry.register(
|
||||
"pistonPushLimit",
|
||||
GameRules.Category.MISC,
|
||||
GameRuleFactory.createIntRule(12, 0, 512)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.youhavetrouble.moregamerules.mixin;
|
||||
|
||||
import me.youhavetrouble.moregamerules.ExtraGameRule;
|
||||
import net.minecraft.block.piston.PistonHandler;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@Mixin(PistonHandler.class)
|
||||
public class PistonPushLimitMixin {
|
||||
|
||||
@ModifyConstant(method = "tryMove", constant = @Constant(intValue = 12))
|
||||
private int injectedPushLimit(int range) throws NoSuchFieldException, IllegalAccessException {
|
||||
PistonHandler pistonHandler = (PistonHandler)(Object) this;
|
||||
|
||||
// Get the associated world
|
||||
Field worldField = PistonHandler.class.getDeclaredField("world");
|
||||
worldField.setAccessible(true);
|
||||
World world = (World) worldField.get(pistonHandler);
|
||||
|
||||
return world.getGameRules().getInt(ExtraGameRule.PISTON_PUSH_LIMIT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,8 +7,10 @@
|
||||
"gamerule.elytraDamagePerSecond.description": "Controls how much damage elytras take when flying",
|
||||
"gamerule.elytraDamageFromFirework": "Elytra damage from firework boost",
|
||||
"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 trident boost",
|
||||
"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"
|
||||
"gamerule.playerCrits.description": "Decides if players should be able to crit",
|
||||
"gamerule.pistonPushLimit": "Piston push limit",
|
||||
"gamerule.description": "Controls how many blocks pistons can push"
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"mixins": [
|
||||
"FireworkItemMixin",
|
||||
"LivingEntityMixin",
|
||||
"PistonPushLimitMixin",
|
||||
"PlayerEntityMixin",
|
||||
"ServerWorldMixin",
|
||||
"TridentItemMixin"
|
||||
|
||||
Reference in New Issue
Block a user