Skip to content

Commit b1a1dce

Browse files
authored
Fix double chest logging (#314)
1 parent 8dfb227 commit b1a1dce

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.github.quiltservertools.ledger.mixin;
2+
3+
import com.github.quiltservertools.ledger.utility.HandlerWithContext;
4+
import net.minecraft.block.entity.ChestBlockEntity;
5+
import net.minecraft.entity.player.PlayerEntity;
6+
import net.minecraft.entity.player.PlayerInventory;
7+
import net.minecraft.screen.ScreenHandler;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.Shadow;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
13+
14+
@Mixin(targets = "net/minecraft/block/ChestBlock$2$1")
15+
public abstract class ChestBlockMixin {
16+
@Shadow
17+
ChestBlockEntity field_17358;
18+
19+
@Inject(
20+
method = "createMenu(ILnet/minecraft/entity/player/PlayerInventory;Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/screen/ScreenHandler;",
21+
at = @At("RETURN")
22+
)
23+
private void addPositionContext(int i, PlayerInventory playerInventory, PlayerEntity playerEntity, CallbackInfoReturnable<ScreenHandler> cir) {
24+
ScreenHandler screenHandler = cir.getReturnValue();
25+
if (screenHandler != null) {
26+
((HandlerWithContext) screenHandler).setPos(this.field_17358.getPos());
27+
}
28+
}
29+
}

src/main/kotlin/com/github/quiltservertools/ledger/utility/InspectionManager.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import com.github.quiltservertools.ledger.database.DatabaseManager
77
import kotlinx.coroutines.launch
88
import net.minecraft.block.BedBlock
99
import net.minecraft.block.BlockState
10-
import net.minecraft.block.Blocks
1110
import net.minecraft.block.ChestBlock
1211
import net.minecraft.block.DoorBlock
1312
import net.minecraft.block.enums.BedPart
@@ -60,7 +59,7 @@ fun ServerCommandSource.inspectBlock(pos: BlockPos) {
6059
var area = BlockBox(pos)
6160

6261
val state = source.world.getBlockState(pos)
63-
if (state.isOf(Blocks.CHEST)) {
62+
if (state.block is ChestBlock) {
6463
getOtherChestSide(state, pos)?.let {
6564
area = BlockBox.create(pos, it)
6665
}

src/main/resources/ledger.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"BucketDispenserBehaviorMixin",
1111
"BucketItemMixin",
1212
"CampfireBlockEntityMixin",
13+
"ChestBlockMixin",
1314
"DoubleInventoryMixin",
1415
"DyeItemMixin",
1516
"ExplosionImplMixin",

0 commit comments

Comments
 (0)