From c304952069abc9b651ae926e67052795945fb746 Mon Sep 17 00:00:00 2001 From: MehVahdJukaar Date: Wed, 5 Jun 2024 15:33:56 +0200 Subject: [PATCH] ehnanced ladders now check quark:ladders tag. Narrator module keybind fix --- changelog.txt | 7 +++++-- .../module/NarratorReadoutModule.java | 6 ++---- .../tweaks/module/EnhancedLaddersModule.java | 16 +++++++--------- .../quark/mixin/mixins/LadderBlockMixin.java | 9 +-------- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/changelog.txt b/changelog.txt index cf9735f0fa..87d7dd4255 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,2 +1,5 @@ -- Fixed a crash when middle clicking a block and having Variant Selector module off -- Middle clicking a variant block while NOT having its parent variant in hand will now make you select the latter \ No newline at end of file +- Magnets can now push multiple blocks at once +- Magnets can now pull blocks through semi transparent blocks, including other moveable ones like rails +- Variant selector will properly delegate method calls to the selected block placement logic +- Enhanced ladders features will now only be applied to blocks in the quark:ladders tag +- Fixed an issue with NarratorReaduout module and its keybinds not being registered if module is turned off \ No newline at end of file diff --git a/src/main/java/org/violetmoon/quark/content/experimental/module/NarratorReadoutModule.java b/src/main/java/org/violetmoon/quark/content/experimental/module/NarratorReadoutModule.java index 04c11f3c16..8b06a2623a 100644 --- a/src/main/java/org/violetmoon/quark/content/experimental/module/NarratorReadoutModule.java +++ b/src/main/java/org/violetmoon/quark/content/experimental/module/NarratorReadoutModule.java @@ -43,10 +43,8 @@ public static class Client extends NarratorReadoutModule { @LoadEvent public void registerKeybinds(ZKeyMapping event) { - if(enabled) { - keybind = event.init("quark.keybind.narrator_readout", null, QuarkClient.MISC_GROUP); - keybindFull = event.init("quark.keybind.narrator_full_readout", null, QuarkClient.MISC_GROUP); - } + keybind = event.init("quark.keybind.narrator_readout", null, QuarkClient.MISC_GROUP); + keybindFull = event.init("quark.keybind.narrator_full_readout", null, QuarkClient.MISC_GROUP); } @PlayEvent diff --git a/src/main/java/org/violetmoon/quark/content/tweaks/module/EnhancedLaddersModule.java b/src/main/java/org/violetmoon/quark/content/tweaks/module/EnhancedLaddersModule.java index 8789a9503f..f62a31aa13 100644 --- a/src/main/java/org/violetmoon/quark/content/tweaks/module/EnhancedLaddersModule.java +++ b/src/main/java/org/violetmoon/quark/content/tweaks/module/EnhancedLaddersModule.java @@ -10,6 +10,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; +import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; import net.minecraft.tags.TagKey; import net.minecraft.world.InteractionHand; @@ -65,10 +66,12 @@ public class EnhancedLaddersModule extends ZetaModule { private static boolean staticEnabled; private static TagKey laddersTag; + private static TagKey laddersBlockTag; @LoadEvent public final void setup(ZCommonSetup event) { laddersTag = ItemTags.create(new ResourceLocation(Quark.MOD_ID, "ladders")); + laddersBlockTag = BlockTags.create(new ResourceLocation(Quark.MOD_ID, "ladders")); } @LoadEvent @@ -116,31 +119,26 @@ private static boolean canAttachTo(BlockState state, Block ladder, LevelReader w return false; } + // replaces ladder survives logic public static boolean canLadderSurvive(BlockState state, LevelReader world, BlockPos pos) { if(!staticEnabled || !allowFreestanding) return false; + if(!state.is(laddersBlockTag))return false; Direction facing = state.getValue(LadderBlock.FACING); Direction opposite = facing.getOpposite(); BlockPos oppositePos = pos.relative(opposite); BlockState oppositeState = world.getBlockState(oppositePos); - boolean solid = facing.getAxis() != Axis.Y && oppositeState.isFaceSturdy(world, oppositePos, facing) && !(oppositeState.getBlock() instanceof LadderBlock); + boolean solid = oppositeState.isFaceSturdy(world, oppositePos, facing) && !(oppositeState.getBlock() instanceof LadderBlock); BlockState topState = world.getBlockState(pos.above()); return solid || (topState.getBlock() instanceof LadderBlock && (facing.getAxis() == Axis.Y || topState.getValue(LadderBlock.FACING) == facing)); } - public static boolean updateLadder(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos currentPos, BlockPos facingPos) { - if(!staticEnabled || !allowFreestanding) - return true; - - return canLadderSurvive(state, world, currentPos); - } @PlayEvent public void onInteract(ZRightClickBlock event) { - if(!allowDroppingDown) - return; + if(!allowDroppingDown) return; Player player = event.getPlayer(); InteractionHand hand = event.getHand(); diff --git a/src/main/java/org/violetmoon/quark/mixin/mixins/LadderBlockMixin.java b/src/main/java/org/violetmoon/quark/mixin/mixins/LadderBlockMixin.java index dc221012d3..1b399f98d0 100644 --- a/src/main/java/org/violetmoon/quark/mixin/mixins/LadderBlockMixin.java +++ b/src/main/java/org/violetmoon/quark/mixin/mixins/LadderBlockMixin.java @@ -18,6 +18,7 @@ @Mixin(LadderBlock.class) public class LadderBlockMixin { + @Inject(method = "canSurvive", at = @At("HEAD"), cancellable = true) private void canSurvive(BlockState state, LevelReader level, BlockPos pos, CallbackInfoReturnable callbackInfoReturnable) { if(EnhancedLaddersModule.canLadderSurvive(state, level, pos)) { @@ -26,12 +27,4 @@ private void canSurvive(BlockState state, LevelReader level, BlockPos pos, Callb } } - @Inject(method = "updateShape", at = @At("HEAD"), cancellable = true) - private void updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor world, BlockPos currentPos, BlockPos facingPos, CallbackInfoReturnable callbackInfoReturnable) { - if(!EnhancedLaddersModule.updateLadder(state, facing, facingState, world, currentPos, facingPos)) { - callbackInfoReturnable.setReturnValue(Blocks.AIR.defaultBlockState()); - callbackInfoReturnable.cancel(); - } - } - }