Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@

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.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.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@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<Boolean> cir, @Local BlockState state) {
if (!state.getBlock().equals(Blocks.LILY_PAD)) return;
World world = (World) (Object) this;
@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, pos, state, null, Sources.VEHICLE, player);
BlockBreakCallback.EVENT.invoker().breakBlock(world, new BlockPos(pos), state, null, Sources.VEHICLE, player);
} else {
BlockBreakCallback.EVENT.invoker().breakBlock(world, pos, state, null, Sources.VEHICLE);
BlockBreakCallback.EVENT.invoker().breakBlock(world, new BlockPos(pos), state, null, Sources.VEHICLE);
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/ledger.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"HoneycombItemMixin",
"ItemScattererMixin",
"JukeboxPlayableComponentMixin",
"LilyPadBreakageMixin",
"LilyPadBlockMixin",
"LockableContainerBlockEntityMixin",
"MoveItemsTaskMixin",
"NetherPortalMixin",
Expand Down