Skip to content
Open
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
@@ -0,0 +1,37 @@
package com.github.quiltservertools.ledger.mixin;

import com.github.quiltservertools.ledger.callbacks.BlockChangeCallback;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.DebugStickItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;

@Mixin(DebugStickItem.class)
public abstract class DebugStickItemMixin {
@ModifyArgs(
method = "handleInteraction",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelAccessor;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z"))
private void logDebugStickUsage(Args args, ServerPlayer player, BlockState oldState, LevelAccessor worldAccess, BlockPos pos, boolean update, ItemStack stack) {
if (worldAccess instanceof Level world) {
BlockEntity blockEntity = oldState.hasBlockEntity() ? world.getBlockEntity(pos) : null;
BlockChangeCallback.EVENT.invoker().changeBlock(
world,
pos.immutable(),
oldState,
args.get(1),
blockEntity,
blockEntity,
Sources.DEBUG_STICK,
player);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ object Sources {
const val COPPER_GOLEM = "copper_golem"
const val WAX = "wax"
const val REANIMATE = "reanimate"
const val DEBUG_STICK = "debug_stick"
const val UNKNOWN = "unknown"
}
1 change: 1 addition & 0 deletions src/main/resources/ledger.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"CompoundContainerMixin",
"ContainersMixin",
"CopperGolemGiveMixin",
"DebugStickItemMixin",
"DyeItemMixin",
"FillCommandMixin",
"FlintAndSteelItemMixin",
Expand Down