Skip to content

Commit 3946aa5

Browse files
Fix crash when pushing water under lily pad. (#347)
Co-authored-by: Drex <nicknamedrex@gmail.com>
1 parent 3c7d6e2 commit 3946aa5

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBreakageMixin.java renamed to src/main/java/com/github/quiltservertools/ledger/mixin/LilyPadBlockMixin.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,26 @@
22

33
import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
44
import com.github.quiltservertools.ledger.utility.Sources;
5-
import com.llamalad7.mixinextras.sugar.Local;
65
import net.minecraft.block.BlockState;
7-
import net.minecraft.block.Blocks;
6+
import net.minecraft.block.LilyPadBlock;
87
import net.minecraft.entity.Entity;
8+
import net.minecraft.entity.EntityCollisionHandler;
99
import net.minecraft.entity.player.PlayerEntity;
1010
import net.minecraft.util.math.BlockPos;
1111
import net.minecraft.world.World;
1212
import org.spongepowered.asm.mixin.Mixin;
1313
import org.spongepowered.asm.mixin.injection.At;
1414
import org.spongepowered.asm.mixin.injection.Inject;
15-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
15+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1616

17-
@Mixin(World.class)
18-
public abstract class LilyPadBreakageMixin {
19-
@Inject(method = "breakBlock", at = @At(value = "RETURN", ordinal = 1))
20-
private void ledgerModifyLilyPadBreakArgs(BlockPos pos, boolean drop, Entity entity, int maxUpdateDepth, CallbackInfoReturnable<Boolean> cir, @Local BlockState state) {
21-
if (!state.getBlock().equals(Blocks.LILY_PAD)) return;
22-
World world = (World) (Object) this;
17+
@Mixin(LilyPadBlock.class)
18+
public abstract class LilyPadBlockMixin {
19+
@Inject(method = "onEntityCollision", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;breakBlock(Lnet/minecraft/util/math/BlockPos;ZLnet/minecraft/entity/Entity;)Z"))
20+
private void ledgerLogLilyPadBreak(BlockState state, World world, BlockPos pos, Entity entity, EntityCollisionHandler handler, boolean bl, CallbackInfo ci) {
2321
if (entity.getFirstPassenger() instanceof PlayerEntity player) {
24-
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.VEHICLE, player);
22+
BlockBreakCallback.EVENT.invoker().breakBlock(world, new BlockPos(pos), state, null, Sources.VEHICLE, player);
2523
} else {
26-
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.VEHICLE);
24+
BlockBreakCallback.EVENT.invoker().breakBlock(world, new BlockPos(pos), state, null, Sources.VEHICLE);
2725
}
2826
}
2927
}

src/main/resources/ledger.mixins.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"HoneycombItemMixin",
2323
"ItemScattererMixin",
2424
"JukeboxPlayableComponentMixin",
25-
"LilyPadBreakageMixin",
25+
"LilyPadBlockMixin",
2626
"LockableContainerBlockEntityMixin",
2727
"MoveItemsTaskMixin",
2828
"NetherPortalMixin",

0 commit comments

Comments
 (0)