diff --git a/src/main/java/com/github/zly2006/carpetslsaddition/SLSCarpetSettings.java b/src/main/java/com/github/zly2006/carpetslsaddition/SLSCarpetSettings.java index fb647b2..6fa7e39 100644 --- a/src/main/java/com/github/zly2006/carpetslsaddition/SLSCarpetSettings.java +++ b/src/main/java/com/github/zly2006/carpetslsaddition/SLSCarpetSettings.java @@ -71,4 +71,10 @@ public class SLSCarpetSettings { @Rule(categories = {SLSA, RuleCategory.FEATURE}) public static boolean turtleLocalNesting = false; + + @Rule(categories = {SLSA, RuleCategory.FEATURE}) + public static boolean sturdyDecoratedPot = false; + + @Rule(categories = {SLSA, RuleCategory.FEATURE}) + public static boolean unbreakableDecoratedPot = false; } diff --git a/src/main/java/com/github/zly2006/carpetslsaddition/mixin/block/MixinDecoratedPotBlock.java b/src/main/java/com/github/zly2006/carpetslsaddition/mixin/block/MixinDecoratedPotBlock.java new file mode 100644 index 0000000..d2bd1dd --- /dev/null +++ b/src/main/java/com/github/zly2006/carpetslsaddition/mixin/block/MixinDecoratedPotBlock.java @@ -0,0 +1,39 @@ +package com.github.zly2006.carpetslsaddition.mixin.block; + +import com.github.zly2006.carpetslsaddition.SLSCarpetSettings; +import net.minecraft.world.entity.projectile.Projectile; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.DecoratedPotBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(DecoratedPotBlock.class) +public class MixinDecoratedPotBlock { + // sturdyDecoratedPot:投掷物命中不碎。 + @Inject(method = "onProjectileHit", at = @At("HEAD"), cancellable = true) + private void sturdyOnProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile, CallbackInfo ci) { + if (SLSCarpetSettings.sturdyDecoratedPot) { + ci.cancel(); + } + } + + // unbreakableDecoratedPot:玩家挖掘时不设 CRACKED(无裂纹效果),仍正常挖掉。 + @Redirect( + method = "playerWillDestroy", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/block/state/BlockState;setValue(Lnet/minecraft/world/level/block/state/properties/Property;Ljava/lang/Comparable;)Ljava/lang/Object;" + ) + ) + private Object noCrackOnPlayerBreak(BlockState state, net.minecraft.world.level.block.state.properties.Property property, Comparable value) { + if (SLSCarpetSettings.unbreakableDecoratedPot) { + return state; + } + return state.setValue(property, value); + } +} \ No newline at end of file diff --git a/src/main/resources/assets/slsaddition/lang/en_us.json b/src/main/resources/assets/slsaddition/lang/en_us.json index 05183b3..c852510 100644 --- a/src/main/resources/assets/slsaddition/lang/en_us.json +++ b/src/main/resources/assets/slsaddition/lang/en_us.json @@ -52,6 +52,10 @@ "carpet.rule.armadilloImmediateDespawns.desc": "Armadillos will despawn immediately if they are 128 blocks away from the player.", "carpet.rule.turtleLocalNesting.name": "Turtle Local Nesting", "carpet.rule.turtleLocalNesting.desc": "Turtles carrying eggs will lay them on reachable sand near the closest local water source instead of returning to their birthplace.", + "carpet.rule.sturdyDecoratedPot.name": "Sturdy Decorated Pot", + "carpet.rule.sturdyDecoratedPot.desc": "Decorated pots are not shattered by projectiles.", + "carpet.rule.unbreakableDecoratedPot.name": "No Crack When Mining Pot", + "carpet.rule.unbreakableDecoratedPot.desc": "Breaking a decorated pot by a player does not produce the cracked effect.", "carpet.rule.trialSpawnerCD.desc": "trialSpawnerCD.", "carpet.rule.skipTicksForJoblessVillager.extra.0": "Set to 0 to maintain the vanilla behavior", diff --git a/src/main/resources/assets/slsaddition/lang/zh_cn.json b/src/main/resources/assets/slsaddition/lang/zh_cn.json index 5d4337a..79a8fa8 100644 --- a/src/main/resources/assets/slsaddition/lang/zh_cn.json +++ b/src/main/resources/assets/slsaddition/lang/zh_cn.json @@ -28,6 +28,10 @@ "carpet.rule.armadilloImmediateDespawns.desc": "当犰狳远离玩家128格时,立即消失", "carpet.rule.turtleLocalNesting.name": "海龟就地筑巢", "carpet.rule.turtleLocalNesting.desc": "有蛋的海龟会在附近的水边沙滩下蛋,而不是返回出生地", + "carpet.rule.sturdyDecoratedPot.name": "坚硬陶罐", + "carpet.rule.sturdyDecoratedPot.desc": "装饰陶罐不会被投掷物击碎", + "carpet.rule.unbreakableDecoratedPot.name": "挖掘陶罐无裂纹", + "carpet.rule.unbreakableDecoratedPot.desc": "玩家破坏装饰陶罐时不会产生裂纹效果", "carpet.rule.obtainableReinforcedDeepSlate.desc": "当铁砧砸在9*64个深板岩的掉落物上时,可以获得强化深板岩", "carpet.rule.skipTicksForJoblessVillager.desc": "对于无业/傻子村民,执行设定数量的tick运算后,跳过1tick的运算", diff --git a/src/main/resources/slsaddition.mixins.json b/src/main/resources/slsaddition.mixins.json index a3833cd..e678be8 100644 --- a/src/main/resources/slsaddition.mixins.json +++ b/src/main/resources/slsaddition.mixins.json @@ -9,6 +9,7 @@ "block.BlockPatternTestTransformInvoker", "block.MixinNetherPortal", "block.MixinRedstoneWireBlock", + "block.MixinDecoratedPotBlock", "block.MixinTrialSpawnerData", "block.MixinTrialSpawnerState", "carpet.MixinEntityPlayerMPFake",