9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-21 07:49:35 +00:00
Files
LeavesMC/patches/server/0076-Container-open-passthrough.patch
2024-01-19 11:09:19 +08:00

37 lines
2.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <58360096+s-yh-china@users.noreply.github.com>
Date: Mon, 17 Jul 2023 11:41:50 +0800
Subject: [PATCH] Container open passthrough
diff --git a/src/main/java/net/minecraft/world/level/block/SignBlock.java b/src/main/java/net/minecraft/world/level/block/SignBlock.java
index 27a1e8ffc43efe4e086e7fd88ee4d80c23f98674..aafe4fd8b406f6b880ab37d39958e57550d5b6a1 100644
--- a/src/main/java/net/minecraft/world/level/block/SignBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java
@@ -117,6 +117,25 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
return InteractionResult.SUCCESS;
} else if (flag2) {
return InteractionResult.SUCCESS;
+ // Leaves start - signContainerPassthrough
+ } else if (top.leavesmc.leaves.LeavesConfig.containerPassthrough) {
+ if (item == net.minecraft.world.item.Items.AIR && player.isShiftKeyDown()) {
+ if (!this.otherPlayerIsEditingSign(player, tileentitysign) && player.mayBuild() && this.hasEditableText(player, tileentitysign, flag1)) {
+ this.openTextEdit(player, tileentitysign, flag1);
+ return InteractionResult.SUCCESS;
+ }
+ }
+
+ BlockPos pos1 = pos.relative(hit.getDirection().getOpposite());
+ if (this instanceof WallSignBlock || this instanceof WallHangingSignBlock) {
+ pos1 = pos.relative(state.getValue(HorizontalDirectionalBlock.FACING).getOpposite());
+ }
+ if (world.getBlockEntity(pos1) instanceof net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) {
+ BlockState state1 = world.getBlockState(pos1);
+ return state1.use(world, player, hand, hit.withPosition(pos1));
+ }
+ return InteractionResult.PASS;
+ // Leaves end - signContainerPassthrough
} else if (!this.otherPlayerIsEditingSign(player, tileentitysign) && player.mayBuild() && this.hasEditableText(player, tileentitysign, flag1)) {
this.openTextEdit(player, tileentitysign, flag1, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.INTERACT); // Paper - Add PlayerOpenSignEvent
return this.getInteractionResult(flag);