mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
* update paper & gradle * Modify merge ItemEntity logic Add followTickSequenceMerge to modify merge items, due to Paper's modification of the merge radius, when the merge radius is large and stacks containing many items get stuck in an unexpected position, individual items may never reach their destination. This configuration option is added to fix this behavior. * add comments
81 lines
5.5 KiB
Diff
81 lines
5.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Mon, 3 Feb 2025 21:31:03 +0800
|
|
Subject: [PATCH] Container open passthrough
|
|
|
|
|
|
diff --git a/net/minecraft/world/entity/decoration/ItemFrame.java b/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
index e6012d2cfe9b84782c8d5a0ba424eeda98086c09..e260ac6b3f4f1b4381f7557ebb3af2866de18da6 100644
|
|
--- a/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
+++ b/net/minecraft/world/entity/decoration/ItemFrame.java
|
|
@@ -421,6 +421,20 @@ public class ItemFrame extends HangingEntity {
|
|
return InteractionResult.PASS;
|
|
}
|
|
} else {
|
|
+ // Leaves start - itemFrameContainerPassthrough
|
|
+ if (org.leavesmc.leaves.LeavesConfig.modify.containerPassthrough && !player.isShiftKeyDown()) {
|
|
+ BlockPos pos1 = this.pos.relative(this.getDirection().getOpposite());
|
|
+ if (level().getBlockEntity(pos1) instanceof net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) {
|
|
+ BlockState blockState = level().getBlockState(pos1);
|
|
+ net.minecraft.world.phys.BlockHitResult hitResult = new net.minecraft.world.phys.BlockHitResult(Vec3.atCenterOf(pos1), this.getDirection(), pos1, false);
|
|
+ if (flag1) {
|
|
+ return blockState.useItemOn(itemInHand, level(), player, hand, hitResult);
|
|
+ } else {
|
|
+ return blockState.useWithoutItem(level(), player, hitResult);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Leaves end - itemFrameContainerPassthrough
|
|
// Paper start - Add PlayerItemFrameChangeEvent
|
|
io.papermc.paper.event.player.PlayerItemFrameChangeEvent event = new io.papermc.paper.event.player.PlayerItemFrameChangeEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.ItemFrame) this.getBukkitEntity(), this.getItem().asBukkitCopy(), io.papermc.paper.event.player.PlayerItemFrameChangeEvent.ItemFrameChangeAction.ROTATE);
|
|
if (!event.callEvent()) {
|
|
diff --git a/net/minecraft/world/level/block/SignBlock.java b/net/minecraft/world/level/block/SignBlock.java
|
|
index a2c6b0f85535b286c5649352f49e448ad587655c..3d62414778f8e18aebfa67817a86f188cb90c614 100644
|
|
--- a/net/minecraft/world/level/block/SignBlock.java
|
|
+++ b/net/minecraft/world/level/block/SignBlock.java
|
|
@@ -108,6 +108,18 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
|
|
} else {
|
|
return InteractionResult.TRY_WITH_EMPTY_HAND;
|
|
}
|
|
+ // Leaves start - signContainerPassthrough
|
|
+ } else if (org.leavesmc.leaves.LeavesConfig.modify.containerPassthrough) {
|
|
+ BlockPos pos1 = pos.relative(hitResult.getDirection().getOpposite());
|
|
+ if (this instanceof WallSignBlock || this instanceof WallHangingSignBlock) {
|
|
+ pos1 = pos.relative(state.getValue(HorizontalDirectionalBlock.FACING).getOpposite());
|
|
+ }
|
|
+ if (level.getBlockEntity(pos1) instanceof net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) {
|
|
+ BlockState state1 = level.getBlockState(pos1);
|
|
+ return state1.useItemOn(stack, level, player, hand, hitResult.withPosition(pos1));
|
|
+ }
|
|
+ return InteractionResult.PASS;
|
|
+ // Leaves end - signContainerPassthrough
|
|
} else {
|
|
return InteractionResult.TRY_WITH_EMPTY_HAND;
|
|
}
|
|
@@ -130,6 +142,25 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
|
|
return InteractionResult.SUCCESS_SERVER;
|
|
} else if (flag) {
|
|
return InteractionResult.SUCCESS_SERVER;
|
|
+ // Leaves start - signContainerPassthrough
|
|
+ } else if (org.leavesmc.leaves.LeavesConfig.modify.containerPassthrough) {
|
|
+ if (player.isShiftKeyDown()) {
|
|
+ if (!this.otherPlayerIsEditingSign(player, signBlockEntity) && player.mayBuild() && this.hasEditableText(player, signBlockEntity, isFacingFrontText)) {
|
|
+ this.openTextEdit(player, signBlockEntity, isFacingFrontText);
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ BlockPos pos1 = pos.relative(hitResult.getDirection().getOpposite());
|
|
+ if (this instanceof WallSignBlock || this instanceof WallHangingSignBlock) {
|
|
+ pos1 = pos.relative(state.getValue(HorizontalDirectionalBlock.FACING).getOpposite());
|
|
+ }
|
|
+ if (level.getBlockEntity(pos1) instanceof net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) {
|
|
+ BlockState state1 = level.getBlockState(pos1);
|
|
+ return state1.useWithoutItem(level, player, hitResult.withPosition(pos1));
|
|
+ }
|
|
+ return InteractionResult.PASS;
|
|
+ // Leaves end - signContainerPassthrough
|
|
} else if (!this.otherPlayerIsEditingSign(player, signBlockEntity)
|
|
&& player.mayBuild()
|
|
&& this.hasEditableText(player, signBlockEntity, isFacingFrontText)) {
|