From 3593b1e93078d34cb9d26f5082d10c2136e34cd2 Mon Sep 17 00:00:00 2001 From: Acuadragon100 <30689683+Acuadragon100@users.noreply.github.com> Date: Tue, 11 Nov 2025 21:13:07 +0100 Subject: [PATCH 1/2] Fix crash when pushing water under lily pad. --- .../ledger/mixin/LilyPadBreakageMixin.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBreakageMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBreakageMixin.java index 0af91c6a..5c39faa1 100644 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBreakageMixin.java +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBreakageMixin.java @@ -7,6 +7,7 @@ import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.vehicle.VehicleEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; @@ -20,10 +21,12 @@ public abstract class LilyPadBreakageMixin { private void ledgerModifyLilyPadBreakArgs(BlockPos pos, boolean drop, Entity entity, int maxUpdateDepth, CallbackInfoReturnable cir, @Local BlockState state) { if (!state.getBlock().equals(Blocks.LILY_PAD)) return; World world = (World) (Object) this; - if (entity.getFirstPassenger() instanceof PlayerEntity player) { - BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.VEHICLE, player); - } else { - BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.VEHICLE); + if (entity instanceof VehicleEntity) { + if (entity.getFirstPassenger() instanceof PlayerEntity player) { + BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.VEHICLE, player); + } else { + BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.VEHICLE); + } } } } \ No newline at end of file From 5a307b36645480380ea696da209be523fd17a9f5 Mon Sep 17 00:00:00 2001 From: Drex Date: Thu, 13 Nov 2025 18:22:13 +0100 Subject: [PATCH 2/2] Improve mixin target --- .../ledger/mixin/LilyPadBlockMixin.java | 27 ++++++++++++++++ .../ledger/mixin/LilyPadBreakageMixin.java | 32 ------------------- src/main/resources/ledger.mixins.json | 2 +- 3 files changed, 28 insertions(+), 33 deletions(-) create mode 100644 src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBlockMixin.java delete mode 100644 src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBreakageMixin.java diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBlockMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBlockMixin.java new file mode 100644 index 00000000..03c99de5 --- /dev/null +++ b/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBlockMixin.java @@ -0,0 +1,27 @@ +package com.github.quiltservertools.ledger.mixin; + +import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback; +import com.github.quiltservertools.ledger.utility.Sources; +import net.minecraft.block.BlockState; +import net.minecraft.block.LilyPadBlock; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCollisionHandler; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +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.callback.CallbackInfo; + +@Mixin(LilyPadBlock.class) +public abstract class LilyPadBlockMixin { + @Inject(method = "onEntityCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;breakBlock(Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/entity/Entity;)Z")) + private void ledgerLogLilyPadBreak(BlockState state, World world, BlockPos pos, Entity entity, EntityCollisionHandler handler, boolean bl, CallbackInfo ci) { + if (entity.getFirstPassenger() instanceof PlayerEntity player) { + BlockBreakCallback.EVENT.invoker().breakBlock(world, new BlockPos(pos), state, null, Sources.VEHICLE, player); + } else { + BlockBreakCallback.EVENT.invoker().breakBlock(world, new BlockPos(pos), state, null, Sources.VEHICLE); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBreakageMixin.java b/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBreakageMixin.java deleted file mode 100644 index 5c39faa1..00000000 --- a/src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBreakageMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.github.quiltservertools.ledger.mixin; - -import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback; -import com.github.quiltservertools.ledger.utility.Sources; -import com.llamalad7.mixinextras.sugar.Local; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.vehicle.VehicleEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -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.callback.CallbackInfoReturnable; - -@Mixin(World.class) -public abstract class LilyPadBreakageMixin { - @Inject(method = "breakBlock", at = @At(value = "RETURN", ordinal = 1)) - private void ledgerModifyLilyPadBreakArgs(BlockPos pos, boolean drop, Entity entity, int maxUpdateDepth, CallbackInfoReturnable cir, @Local BlockState state) { - if (!state.getBlock().equals(Blocks.LILY_PAD)) return; - World world = (World) (Object) this; - if (entity instanceof VehicleEntity) { - if (entity.getFirstPassenger() instanceof PlayerEntity player) { - BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.VEHICLE, player); - } else { - BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.VEHICLE); - } - } - } -} \ No newline at end of file diff --git a/src/main/resources/ledger.mixins.json b/src/main/resources/ledger.mixins.json index 254611b8..f0584897 100644 --- a/src/main/resources/ledger.mixins.json +++ b/src/main/resources/ledger.mixins.json @@ -22,7 +22,7 @@ "HoneycombItemMixin", "ItemScattererMixin", "JukeboxPlayableComponentMixin", - "LilyPadBreakageMixin", + "LilyPadBlockMixin", "LockableContainerBlockEntityMixin", "MoveItemsTaskMixin", "NetherPortalMixin",