Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1bcaf2b
fix: log armor stand equipment before it is dropped on break
Sep 6, 2026
0544eec
fix: log item drops when a player dies
Sep 27, 2026
2589e43
feat: add rollback button to single search and inspect results
Sep 27, 2026
0e2053e
feat: log item despawns
Sep 27, 2026
727ed5f
Merge branch 'feat/rollback-single' into server
Sep 27, 2026
b06ad2b
Merge branch 'feat/item-despawn' into server
Sep 27, 2026
edbd457
feat: require extra permission to roll back item despawns
Sep 27, 2026
be5a2f8
Merge branch 'feat/item-despawn' into server
Sep 27, 2026
784223b
fix: check item-despawn permission for single rollbacks
Sep 27, 2026
b55b929
feat: log tools and armor breaking
Oct 2, 2026
4cc4354
Merge branch 'feat/item-break' into server
Oct 2, 2026
bb0239a
Merge branch 'QuiltServerTools:master' into master
ShortByte Oct 14, 2026
f5a618d
Merge branch 'QuiltServerTools:master' into server
ShortByte Oct 14, 2026
29e2d46
Merge pull request #1 from ShortByte/server
ShortByte Oct 14, 2026
959ce8c
feat: only show the rollback button to players allowed to roll back
Oct 14, 2026
1fc5260
Merge branch 'feat/rollback-single' into server
Oct 14, 2026
c9bf2ea
fix: hide the rollback button on item despawns without permission
Oct 14, 2026
1011a79
Merge pull request #2 from ShortByte/server
ShortByte Oct 14, 2026
027cba5
feat: log items renamed in an anvil
Oct 14, 2026
35330d2
fix: log stone formed by lava flowing into water
Oct 14, 2026
a7cf6c9
fix: stop attributing lever and button changes to a stale player
Oct 14, 2026
4f36449
feat: log blocks toggled by wind charges
Oct 14, 2026
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
5 changes: 5 additions & 0 deletions docs/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ These are the currently logged action types:
- block-change
- item-insert
- item-remove
- item-pick-up
- item-drop
- item-despawn
- item-break
- item-rename
- entity-killed
- entity-mount
- entity-dismount
7 changes: 6 additions & 1 deletion docs/commands/rollback.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ It is ***highly*** recommended to use the [preview command](../commands/preview.

- Block
- Item
- Entity
- Entity

**Despawned items**

Rolling back `item-despawn` actions additionally requires `ledger.commands.rollback.item-despawn` (defaults to permission level 4).
Without it, despawned items are left out of rollbacks and previews, and explicitly searching for `action:item-despawn` fails.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

import com.github.quiltservertools.ledger.callbacks.BlockBreakCallback;
import com.github.quiltservertools.ledger.callbacks.BlockChangeCallback;
import com.github.quiltservertools.ledger.callbacks.ItemRenameCallback;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.core.component.DataComponents;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.inventory.ItemCombinerMenu;
import net.minecraft.world.inventory.ItemCombinerMenuSlotDefinition;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AnvilMenu;
Expand All @@ -15,8 +24,31 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;

import java.util.Objects;

@Mixin(AnvilMenu.class)
public abstract class AnvilMenuMixin {
public abstract class AnvilMenuMixin extends ItemCombinerMenu {
private AnvilMenuMixin(MenuType<?> menuType, int containerId, Inventory inventory, ContainerLevelAccess access, ItemCombinerMenuSlotDefinition itemInputSlots) {
super(menuType, containerId, inventory, access, itemInputSlots);
}

// Runs before the anvil consumes its inputs, so the first input slot still holds the item as it
// was before the rename. Taking a result that was only repaired or enchanted keeps the old name
// and is not logged.
@Inject(method = "onTake", at = @At("HEAD"))
private void ledgerLogItemRename(Player player, ItemStack result, CallbackInfo ci) {
if (!(player instanceof ServerPlayer)) {
return;
}

ItemStack original = this.inputSlots.getItem(AnvilMenu.INPUT_SLOT);
if (Objects.equals(original.get(DataComponents.CUSTOM_NAME), result.get(DataComponents.CUSTOM_NAME))) {
return;
}

BlockPos pos = this.access.evaluate((world, blockPos) -> blockPos, player.blockPosition());
ItemRenameCallback.EVENT.invoker().rename(player, pos, original.copy(), result.copy());
}

@Inject(method = "lambda$onTake$0",
at = @At(value = "INVOKE",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.github.quiltservertools.ledger.mixin;

import com.github.quiltservertools.ledger.callbacks.ItemDropCallback;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityEquipment;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(EntityEquipment.class)
public abstract class EntityEquipmentMixin {
// Drops armor and offhand when a player dies (called from Inventory#dropAll). Only players are
// logged, matching the regular drop hook in ServerPlayerMixin.
@WrapOperation(method = "dropAll", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z"))
private boolean ledgerLogDeathDrop(Level world, Entity entity, Operation<Boolean> original, @Local(argsOnly = true) LivingEntity owner) {
boolean added = original.call(world, entity);
if (added && owner instanceof Player player && entity instanceof ItemEntity itemEntity) {
ItemDropCallback.EVENT.invoker().drop(itemEntity, player);
}
return added;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.github.quiltservertools.ledger.mixin;

import com.github.quiltservertools.ledger.callbacks.ItemDropCallback;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(Inventory.class)
public abstract class InventoryMixin {
@Shadow
@Final
public Player player;

// On death the inventory spawns its items directly instead of going through Player#drop, so
// the drop hook in ServerPlayerMixin never sees them. Armor and offhand are handled in
// EntityEquipmentMixin.
@WrapOperation(method = "dropAll", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z"))
private boolean ledgerLogDeathDrop(Level world, Entity entity, Operation<Boolean> original) {
boolean added = original.call(world, entity);
if (added && entity instanceof ItemEntity itemEntity) {
ItemDropCallback.EVENT.invoker().drop(itemEntity, this.player);
}
return added;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.github.quiltservertools.ledger.mixin;

import com.github.quiltservertools.ledger.callbacks.ItemBreakCallback;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
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;

import java.util.function.Consumer;

@Mixin(ItemStack.class)
public abstract class ItemStackMixin {
// Every durability loss (tools, weapons, worn armor) ends up here. The player is null when the
// item is not held or worn by a player, e.g. a mob's armor.
@Inject(method = "applyDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;shrink(I)V"))
private void ledgerLogItemBreak(int damage, ServerPlayer player, Consumer<ItemStack> onBreak, CallbackInfo ci) {
if (player != null) {
ItemBreakCallback.EVENT.invoker().breakItem((ItemStack) (Object) this, player);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.quiltservertools.ledger.mixin;

import com.github.quiltservertools.ledger.commands.subcommands.PageCommand;
import com.github.quiltservertools.ledger.commands.subcommands.RollbackCommand;
import com.github.quiltservertools.ledger.commands.subcommands.TeleportCommand;
import com.github.quiltservertools.ledger.utility.MessageUtils;
import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -54,6 +55,14 @@ private void handleLedgerPageChangeClick(ServerboundCustomClickActionPacket pack
TeleportCommand.INSTANCE.teleport(player, serverLevel, pos);
});
ci.cancel();
} else if (packet.id().equals(MessageUtils.INSTANCE.getRollbackAction())) {
ServerPlayer player = game.player;
packet.payload().flatMap(Tag::asCompound)
.flatMap(root -> root.getInt("id"))
.ifPresent(actionId ->
RollbackCommand.INSTANCE.rollbackSingle(player, actionId)
);
ci.cancel();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
package com.github.quiltservertools.ledger.mixin;

import com.github.quiltservertools.ledger.callbacks.BlockChangeCallback;
import com.github.quiltservertools.ledger.callbacks.BlockPlaceCallback;
import com.github.quiltservertools.ledger.utility.ExplosionHitTracker;
import com.github.quiltservertools.ledger.utility.PlayerCausable;
import com.github.quiltservertools.ledger.utility.Sources;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import java.util.List;
import java.util.function.BiConsumer;
import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.ServerExplosion;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand Down Expand Up @@ -46,27 +54,68 @@ public abstract class ServerExplosionMixin {
private void ledgerExplosionFireCallback(List<BlockPos> positions, CallbackInfo ci, @Local BlockPos blockPos) {
BlockState blockState = BaseFireBlock.getState(level, blockPos);

BlockPlaceCallback.EVENT.invoker().place(
level,
blockPos,
blockState,
level.getBlockEntity(blockPos) != null ? level.getBlockEntity(blockPos) : null,
ledgerGetSourceName(),
ledgerGetCausingPlayer()
);
}

// Explosions that trigger blocks instead of destroying them (wind charges) toggle doors,
// trapdoors, fence gates, levers and buttons and blow out candles. Log every hit that leaves the
// same block in a different state; blocks that were destroyed are logged as broken elsewhere.
@WrapOperation(
method = "interactWithBlocks",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/block/state/BlockState;onExplosionHit(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/Explosion;Ljava/util/function/BiConsumer;)V"
)
)
private void ledgerLogExplosionHit(BlockState state, ServerLevel world, BlockPos pos, Explosion explosion, BiConsumer<ItemStack, BlockPos> dropConsumer, Operation<Void> original) {
boolean wasActive = ExplosionHitTracker.getActive();
ExplosionHitTracker.setActive(true);
try {
original.call(state, world, pos, explosion, dropConsumer);
} finally {
ExplosionHitTracker.setActive(wasActive);
}

BlockState newState = world.getBlockState(pos);
if (newState == state || !newState.is(state.getBlock())) {
return;
}

BlockChangeCallback.EVENT.invoker().changeBlock(
world,
pos,
state,
newState,
null,
null,
ledgerGetSourceName(),
ledgerGetCausingPlayer()
);
}

@Unique
private @Nullable Player ledgerGetCausingPlayer() {
LivingEntity entity;
if (this.source instanceof PlayerCausable playerCausable && playerCausable.getCausingPlayer() != null) {
entity = playerCausable.getCausingPlayer();
} else {
entity = getIndirectSourceEntity();
}
return entity instanceof Player player ? player : null;
}

String source;
@Unique
private String ledgerGetSourceName() {
if (this.source != null && !(this.source instanceof Player)) {
source = BuiltInRegistries.ENTITY_TYPE.getKey(this.source.getType()).getPath();
} else {
source = Sources.EXPLOSION;
return BuiltInRegistries.ENTITY_TYPE.getKey(this.source.getType()).getPath();
}

BlockPlaceCallback.EVENT.invoker().place(
level,
blockPos,
blockState,
level.getBlockEntity(blockPos) != null ? level.getBlockEntity(blockPos) : null,
source,
entity instanceof Player player ? player : null
);
return Sources.EXPLOSION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ public void logLeverUse(Args args, BlockState state, Level world, BlockPos pos,
BlockState newState = args.get(1);
BlockChangeCallback.EVENT.invoker().changeBlock(world, pos, state, newState, null, null, activePlayer);
}

// One LeverBlock/ButtonBlock instance is shared by every placed lever/button, so the player has
// to be cleared again. Otherwise a later pull/press without a player (wind charge) would be
// attributed to whoever used one last.
@Inject(method = "useWithoutItem", at = @At("RETURN"))
public void clearPlayer(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit, CallbackInfoReturnable<InteractionResult> cir) {
activePlayer = null;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.quiltservertools.ledger.mixin.blocks;

import com.github.quiltservertools.ledger.callbacks.BlockChangeCallback;
import com.github.quiltservertools.ledger.utility.ExplosionHitTracker;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.world.level.block.AbstractCandleBlock;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -27,6 +28,9 @@ public abstract class CandleBlockMixin {

@Inject(method = "extinguish", at = @At(value = "RETURN"))
private static void ledgerLogCandleExtinguish(Player player, BlockState state, LevelAccessor worldAccess, BlockPos pos, CallbackInfo ci) {
// Blown out by a wind charge: logged by ServerExplosionMixin with the charge as source
if (ExplosionHitTracker.getActive()) return;

if (worldAccess instanceof Level world) {
BlockChangeCallback.EVENT.invoker().changeBlock(
world,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.github.quiltservertools.ledger.mixin.blocks;

import com.github.quiltservertools.ledger.callbacks.BlockPlaceCallback;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.LavaFluid;
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(LavaFluid.class)
public abstract class LavaFluidMixin {
// Lava flowing down into water turns it into stone. This bypasses LiquidBlock#shouldSpreadLiquid,
// which only covers water reaching lava (cobblestone, obsidian).
@Inject(
method = "spreadTo",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/LevelAccessor;setBlockAndUpdate(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z")
)
private void ledgerLogStoneForm(LevelAccessor world, BlockPos pos, BlockState state, Direction direction, FluidState fluidState, CallbackInfo ci) {
if (world instanceof Level level) {
BlockPlaceCallback.EVENT.invoker().place(
level,
pos,
Blocks.STONE.defaultBlockState(),
null,
Sources.FLUID
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ public void logLeverUse(Args args, BlockState state, Level world, BlockPos pos,
BlockState newState = args.get(1);
BlockChangeCallback.EVENT.invoker().changeBlock(world, pos, state, newState, null, null, activePlayer);
}

// One LeverBlock/ButtonBlock instance is shared by every placed lever/button, so the player has
// to be cleared again. Otherwise a later pull/press without a player (wind charge) would be
// attributed to whoever used one last.
@Inject(method = "useWithoutItem", at = @At("RETURN"))
public void clearPlayer(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit, CallbackInfoReturnable<InteractionResult> cir) {
activePlayer = null;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.quiltservertools.ledger.mixin.blocks;

import com.github.quiltservertools.ledger.callbacks.BlockChangeCallback;
import com.github.quiltservertools.ledger.utility.ExplosionHitTracker;
import com.github.quiltservertools.ledger.utility.Sources;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -25,6 +26,9 @@ public abstract class TrapDoorBlockMixin {

@Inject(method = "toggle", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z"))
public void logTrapdoorInteraction(BlockState state, Level world, BlockPos pos, Player player, CallbackInfo ci) {
// Toggled by a wind charge: logged by ServerExplosionMixin with the charge as source
if (ExplosionHitTracker.getActive()) return;

BlockChangeCallback.EVENT.invoker().changeBlock(world, pos, state.cycle(OPEN), state, null, null, Sources.INTERACT, player);
}

Expand Down
Loading