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.
This commit is contained in:
Helvetica Volubi
2025-10-04 01:15:49 +08:00
parent 482809df6e
commit 15a55403ff
3 changed files with 40 additions and 2 deletions
@@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
Date: Fri, 3 Oct 2025 19:43:36 +0800
Subject: [PATCH] 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.
diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java
index e5e8c752129a6ebb0dd1315c9b8ec459be11ef07..dfd202a74ec7f2cdb9cdc208a6428090a110f811 100644
--- a/net/minecraft/world/entity/item/ItemEntity.java
+++ b/net/minecraft/world/entity/item/ItemEntity.java
@@ -295,7 +295,7 @@ public class ItemEntity extends Entity implements TraceableEntity, ChangePublish
ItemStack item = this.getItem();
ItemStack item1 = itemEntity.getItem();
if (Objects.equals(this.target, itemEntity.target) && areMergable(item, item1)) {
- if (item1.getCount() < item.getCount()) {
+ if (fun.bm.lophine.config.modules.misc.ItemEntityConfig.followTickSequenceMerge || item1.getCount() < item.getCount()) { // Lophine - add follow Tick Sequence Merge, see Paper#13073
merge(this, item, itemEntity, item1);
} else {
merge(itemEntity, item1, this, item);
@@ -23,14 +23,16 @@ public class ContainerExpansionConfig implements IConfigModule {
range: 1~6""") range: 1~6""")
public static int enderchestRows = 3; public static int enderchestRows = 3;
@TransformedConfig(name = "shulker_stackable_count", directory = {"function", "container_expansion"})
@TransformedConfig(name = "shulker_stackable_count", directory = {"misc", "container_expansion"}) @TransformedConfig(name = "shulker_stackable_count", directory = {"misc", "container_expansion"})
@CommandSuggestions(suggest = {"1", "2", "32", "64"}) @CommandSuggestions(suggest = {"1", "2", "32", "64"})
@ConfigInfo(name = "shulker_stackable_count", comments = @ConfigInfo(name = "shulker_stackable_count", directory = {"shulker_box"}, comments =
""" """
range: 1~64""") range: 1~64""")
public static int shulkerCount = 1; public static int shulkerCount = 1;
@TransformedConfig(name = "same_nbt_shulker_stackable", directory = {"function", "container_expansion"})
@TransformedConfig(name = "same_nbt_shulker_stackable", directory = {"misc", "container_expansion"}) @TransformedConfig(name = "same_nbt_shulker_stackable", directory = {"misc", "container_expansion"})
@ConfigInfo(name = "same_nbt_shulker_stackable") @ConfigInfo(name = "same_nbt_shulker_stackable", directory = {"shulker_box"})
public static boolean nbtShulkerStackable = false; public static boolean nbtShulkerStackable = false;
} }
@@ -0,0 +1,16 @@
package fun.bm.lophine.config.modules.misc;
import me.earthme.luminol.config.IConfigModule;
import me.earthme.luminol.config.flags.ConfigClassInfo;
import me.earthme.luminol.config.flags.ConfigInfo;
import me.earthme.luminol.enums.EnumConfigCategory;
@ConfigClassInfo(category = EnumConfigCategory.MISC, name = "item-entity")
public class ItemEntityConfig implements IConfigModule {
@ConfigInfo(name = "follow-tick-sequence-merge", comments = """
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.""")
public static boolean followTickSequenceMerge = false;
}