diff --git a/lophine-server/minecraft-patches/features/0012-Leaves-Vanilla-hopper.patch b/lophine-server/minecraft-patches/features/0012-Leaves-Vanilla-hopper.patch new file mode 100644 index 0000000..818525c --- /dev/null +++ b/lophine-server/minecraft-patches/features/0012-Leaves-Vanilla-hopper.patch @@ -0,0 +1,86 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Helvetica Volubi +Date: Mon, 28 Jul 2025 01:06:40 +0800 +Subject: [PATCH] Leaves: Vanilla hopper + +Co-authored by: violetc <58360096+s-yh-china@users.noreply.github.com> +As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/2c9f83c7b99178851edf5608b37b8c2adddd93cd/leaves-server/minecraft-patches/features/0095-Vanilla-hopper.patch) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java +index 8ba900fda7cce45679cde2b8b3272654129135ca..9d7ec9f4f18ed263540ccddf16c6c1a92d3477a4 100644 +--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java +@@ -280,36 +280,49 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + ItemStack movedItem = origItemStack; + final int originalItemCount = origItemStack.getCount(); + final int movedItemCount = Math.min(level.spigotConfig.hopperAmount, originalItemCount); +- container.setChanged(); // original logic always marks source inv as changed even if no move happens. +- movedItem.setCount(movedItemCount); + +- if (!worldData.skipPullModeEventFire) { // Folia - region threading +- movedItem = callPullMoveEvent(hopper, container, movedItem); +- if (movedItem == null) { // cancelled ++ // Leaves start - fix vanilla ++ if (fun.bm.lophine.config.modules.misc.RedStoneConfig.vanillaHopper && movedItem.getCount() <= movedItemCount) { ++ movedItem = origItemStack.copy(); ++ final ItemStack remainingItem = addItem(container, hopper, container.removeItem(i, movedItemCount), null); ++ if (remainingItem.isEmpty()) { ++ container.setChanged(); ++ return true; ++ } ++ container.setItem(i, movedItem); ++ } else { ++ container.setChanged(); // original logic always marks source inv as changed even if no move happens. ++ movedItem.setCount(movedItemCount); ++ ++ if (!worldData.skipPullModeEventFire) { ++ movedItem = callPullMoveEvent(hopper, container, movedItem); ++ if (movedItem == null) { // cancelled ++ origItemStack.setCount(originalItemCount); ++ // Drastically improve performance by returning true. ++ // No plugin could have relied on the behavior of false as the other call ++ // site for IMIE did not exhibit the same behavior ++ return true; ++ } ++ } ++ final ItemStack remainingItem = addItem(container, hopper, movedItem, null); ++ final int remainingItemCount = remainingItem.getCount(); ++ if (remainingItemCount != movedItemCount) { ++ origItemStack = origItemStack.copy(true); + origItemStack.setCount(originalItemCount); +- // Drastically improve performance by returning true. +- // No plugin could have relied on the behavior of false as the other call +- // site for IMIE did not exhibit the same behavior ++ if (!origItemStack.isEmpty()) { ++ origItemStack.setCount(originalItemCount - movedItemCount + remainingItemCount); ++ } ++ ++ IGNORE_TILE_UPDATES.set(true); ++ container.setItem(i, origItemStack); ++ IGNORE_TILE_UPDATES.set(false); ++ container.setChanged(); + return true; + } +- } +- +- final ItemStack remainingItem = addItem(container, hopper, movedItem, null); +- final int remainingItemCount = remainingItem.getCount(); +- if (remainingItemCount != movedItemCount) { +- origItemStack = origItemStack.copy(true); + origItemStack.setCount(originalItemCount); +- if (!origItemStack.isEmpty()) { +- origItemStack.setCount(originalItemCount - movedItemCount + remainingItemCount); +- } + +- IGNORE_TILE_UPDATES.set(true); // Folia - region threading +- container.setItem(i, origItemStack); +- IGNORE_TILE_UPDATES.set(false); // Folia - region threading +- container.setChanged(); +- return true; + } +- origItemStack.setCount(originalItemCount); ++ // Leaves end - fix vanilla + + if (level.paperConfig().hopper.cooldownWhenFull) { + applyCooldown(hopper); diff --git a/lophine-server/minecraft-patches/features/0012-Paper-Fix-quick-craft.patch b/lophine-server/minecraft-patches/features/0013-Paper-Fix-quick-craft.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0012-Paper-Fix-quick-craft.patch rename to lophine-server/minecraft-patches/features/0013-Paper-Fix-quick-craft.patch diff --git a/lophine-server/minecraft-patches/features/0013-Purpur-Barrels-and-enderchests-6-rows.patch b/lophine-server/minecraft-patches/features/0014-Purpur-Barrels-and-enderchests-6-rows.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0013-Purpur-Barrels-and-enderchests-6-rows.patch rename to lophine-server/minecraft-patches/features/0014-Purpur-Barrels-and-enderchests-6-rows.patch diff --git a/lophine-server/minecraft-patches/features/0014-Spawn-invulnerable-time.patch b/lophine-server/minecraft-patches/features/0015-Spawn-invulnerable-time.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0014-Spawn-invulnerable-time.patch rename to lophine-server/minecraft-patches/features/0015-Spawn-invulnerable-time.patch diff --git a/lophine-server/minecraft-patches/features/0015-Old-Explosion-Damage-Calculator.patch b/lophine-server/minecraft-patches/features/0016-Old-Explosion-Damage-Calculator.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0015-Old-Explosion-Damage-Calculator.patch rename to lophine-server/minecraft-patches/features/0016-Old-Explosion-Damage-Calculator.patch diff --git a/lophine-server/minecraft-patches/features/0016-Old-replaceable-by-mushrooms.patch b/lophine-server/minecraft-patches/features/0017-Old-replaceable-by-mushrooms.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0016-Old-replaceable-by-mushrooms.patch rename to lophine-server/minecraft-patches/features/0017-Old-replaceable-by-mushrooms.patch diff --git a/lophine-server/minecraft-patches/features/0017-Old-zombie-reinforcement.patch b/lophine-server/minecraft-patches/features/0018-Old-zombie-reinforcement.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0017-Old-zombie-reinforcement.patch rename to lophine-server/minecraft-patches/features/0018-Old-zombie-reinforcement.patch diff --git a/lophine-server/minecraft-patches/features/0018-I18n-support.patch b/lophine-server/minecraft-patches/features/0019-I18n-support.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0018-I18n-support.patch rename to lophine-server/minecraft-patches/features/0019-I18n-support.patch diff --git a/lophine-server/src/main/java/fun/bm/lophine/config/modules/misc/RedStoneConfig.java b/lophine-server/src/main/java/fun/bm/lophine/config/modules/misc/RedStoneConfig.java index 3a200fa..f429d26 100644 --- a/lophine-server/src/main/java/fun/bm/lophine/config/modules/misc/RedStoneConfig.java +++ b/lophine-server/src/main/java/fun/bm/lophine/config/modules/misc/RedStoneConfig.java @@ -12,6 +12,9 @@ public class RedStoneConfig implements IConfigModule { Allows you to use the Shears to right-click to rotate the block.""") public static boolean shears = false; + @ConfigInfo(baseName = "vanilla_hopper") + public static boolean vanillaHopper = false; + @Override public EnumConfigCategory getCategory() { return EnumConfigCategory.MISC;