Skip to content

Commit

Permalink
close #4359
Browse files Browse the repository at this point in the history
  • Loading branch information
yrsegal committed Oct 2, 2023
1 parent 843ebf5 commit ec05fa5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> nonGriefingEntities = Arrays.asList("minecraft:creeper", "minecraft:enderman");

Expand Down Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/vazkii/quark/mixin/TripWireHookBlockMixin.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
1 change: 1 addition & 0 deletions src/main/resources/quark.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"StructureTemplateMixin",
"TemptGoalMixin",
"TrapDoorBlockMixin",
"TripWireHookBlockMixin",
"WallBlockMixin",
"WeatheringCopperMixin",
"accessor.AccessorAbstractArrow",
Expand Down

0 comments on commit ec05fa5

Please sign in to comment.