9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-20 15:29:35 +00:00
Files
LeavesMC/patches/server/0075-Container-open-passthrough.patch
violetc f40d340092 1.20.6 (#216)
---------

Co-authored-by: MC_XiaoHei <xiaohei.xor7studio@foxmail.com>
Co-authored-by: Bluemangoo <chenfy2006@qq.com>
2024-05-20 23:03:56 +08:00

56 lines
3.7 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 f7bae8060d993176799ff3ff4653d760a137faba..01dcc910e9151fb28828f99afa0adc21f5a700d7 100644
--- a/src/main/java/net/minecraft/world/level/block/SignBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java
@@ -113,6 +113,18 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
} else {
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
+ // Leaves start - signContainerPassthrough
+ } else if (org.leavesmc.leaves.LeavesConfig.containerPassthrough) {
+ 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.useItemOn(stack, world, player, hand, hit.withPosition(pos1));
+ }
+ return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
+ // Leaves end - signContainerPassthrough
} else {
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
@@ -141,6 +153,25 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
return InteractionResult.SUCCESS;
} else if (flag1) {
return InteractionResult.SUCCESS;
+ // Leaves start - signContainerPassthrough
+ } else if (org.leavesmc.leaves.LeavesConfig.containerPassthrough) {
+ if (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.useWithoutItem(world, player, hit.withPosition(pos1));
+ }
+ return InteractionResult.PASS;
+ // Leaves end - signContainerPassthrough
} else if (!this.otherPlayerIsEditingSign(player, tileentitysign) && player.mayBuild() && this.hasEditableText(player, tileentitysign, flag)) {
this.openTextEdit(player, tileentitysign, flag, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.INTERACT); // Paper - Add PlayerOpenSignEvent
return InteractionResult.SUCCESS;