From ec05fa58d95f9cd95288421491ae2c8ca8b40b8b Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Mon, 2 Oct 2023 11:52:52 -0400 Subject: [PATCH] close #4359 --- .../experimental/module/GameNerfsModule.java | 7 ++++++ .../quark/mixin/TripWireHookBlockMixin.java | 23 +++++++++++++++++++ src/main/resources/quark.mixins.json | 1 + 3 files changed, 31 insertions(+) create mode 100644 src/main/java/vazkii/quark/mixin/TripWireHookBlockMixin.java diff --git a/src/main/java/vazkii/quark/content/experimental/module/GameNerfsModule.java b/src/main/java/vazkii/quark/content/experimental/module/GameNerfsModule.java index 7e826ccb43..045e1ccceb 100644 --- a/src/main/java/vazkii/quark/content/experimental/module/GameNerfsModule.java +++ b/src/main/java/vazkii/quark/content/experimental/module/GameNerfsModule.java @@ -78,6 +78,9 @@ public class GameNerfsModule extends QuarkModule { @Config(description = "Fixes mushroom growth being able to replace blocks") public static boolean disableMushroomBlockRemoval = true; + @Config(description = "Makes tripwire hooks unable to be duplicated") + public static boolean disableTripwireHookDupe = true; + @Config public static List nonGriefingEntities = Arrays.asList("minecraft:creeper", "minecraft:enderman"); @@ -120,6 +123,10 @@ public static boolean shouldMushroomsUseTreeReplacementLogic() { return staticEnabled && disableMushroomBlockRemoval; } + public static boolean shouldTripwireHooksCheckForAir() { + return staticEnabled && disableTripwireHookDupe; + } + @SubscribeEvent public void onMobGriefing(EntityMobGriefingEvent event) { if(!enableSelectiveMobGriefing || event.getEntity() == null) diff --git a/src/main/java/vazkii/quark/mixin/TripWireHookBlockMixin.java b/src/main/java/vazkii/quark/mixin/TripWireHookBlockMixin.java new file mode 100644 index 0000000000..ce7ea12a5d --- /dev/null +++ b/src/main/java/vazkii/quark/mixin/TripWireHookBlockMixin.java @@ -0,0 +1,23 @@ +package vazkii.quark.mixin; + +import com.llamalad7.mixinextras.injector.WrapWithCondition; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.TripWireHookBlock; +import net.minecraft.world.level.block.state.BlockState; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import vazkii.quark.content.experimental.module.GameNerfsModule; + +@Mixin(TripWireHookBlock.class) +public class TripWireHookBlockMixin { + + @WrapWithCondition(method = "calculateState", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z")) + private boolean fixTripWireDupe(Level instance, BlockPos pos, BlockState state, int flag) { + if (GameNerfsModule.shouldTripwireHooksCheckForAir() && state.is(Blocks.TRIPWIRE_HOOK)) + return instance.getBlockState(pos).is(Blocks.TRIPWIRE_HOOK); + return true; + } + +} diff --git a/src/main/resources/quark.mixins.json b/src/main/resources/quark.mixins.json index 67a0e73f7e..449de88840 100644 --- a/src/main/resources/quark.mixins.json +++ b/src/main/resources/quark.mixins.json @@ -58,6 +58,7 @@ "StructureTemplateMixin", "TemptGoalMixin", "TrapDoorBlockMixin", + "TripWireHookBlockMixin", "WallBlockMixin", "WeatheringCopperMixin", "accessor.AccessorAbstractArrow",