Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Original project: https://github.com/LeavesMC/Leaves
This is a temporary solution designed to attempt to restore the vanilla behavior of the funnel while preserving optimizations as much as possible. It should ultimately be replaced by the optimization solution provided by lithium.

diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index dab2778068afa42ad8719300852b4ac8495a2a09..e1cf1057e9dd6cc859621d791ec62bbb2bcff04b 100644
index dab2778068afa42ad8719300852b4ac8495a2a09..c3b9880f125aee88f671f5e527043676b70bca4a 100644
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -281,36 +281,67 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -281,36 +281,70 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
ItemStack movedItem = origItemStack;
final int originalItemCount = origItemStack.getCount();
final int movedItemCount = Math.min(level.spigotConfig.hopperAmount, originalItemCount);
Expand All @@ -35,6 +35,9 @@ index dab2778068afa42ad8719300852b4ac8495a2a09..e1cf1057e9dd6cc859621d791ec62bbb
+ final boolean removeOriginalItem = movedItem == origItemStack;
+ if (removeOriginalItem) {
+ movedItem = container.removeItem(i, movedItemCount);
+ if (movedItem == origItemStack) {
+ movedItem = movedItem.copy(true); // copy if reference equal
+ }
+ }

- if (!skipPullModeEventFire) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Replace Lithium tracker list with array


diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index e1cf1057e9dd6cc859621d791ec62bbb2bcff04b..0a622da1b4510922c60e36b587ec385192a46f4f 100644
index c3b9880f125aee88f671f5e527043676b70bca4a..3162c02847a818afa2b9f873f4a75bc87db52e79 100644
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -869,21 +869,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -872,21 +872,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
//Mod count used to avoid transfer attempts that are known to fail (no change since last attempt)
private long insertStackListModCount, extractStackListModCount;

Expand All @@ -33,7 +33,7 @@ index e1cf1057e9dd6cc859621d791ec62bbb2bcff04b..0a622da1b4510922c60e36b587ec3851
@Nullable
private AABB insertInventoryEntityBox;
private long insertInventoryEntityFailedSearchTime;
@@ -965,19 +962,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -968,19 +965,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
((net.caffeinemc.mods.lithium.common.block.entity.inventory_change_tracking.InventoryChangeTracker) this.insertBlockInventory).listenForContentChangesOnce(this.insertStackList, this);
}
if (listenToInsertEntities) {
Expand All @@ -56,7 +56,7 @@ index e1cf1057e9dd6cc859621d791ec62bbb2bcff04b..0a622da1b4510922c60e36b587ec3851
return;
}
net.caffeinemc.mods.lithium.common.tracking.entity.ChunkSectionEntityMovementTracker.listenToEntityMovementOnce(this, collectItemEntityTracker);
@@ -1112,7 +1109,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -1115,7 +1112,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
private void invalidateInsertionData() {
if (this.level instanceof net.minecraft.server.level.ServerLevel) {
if (this.insertInventoryEntityTracker != null) {
Expand All @@ -65,7 +65,7 @@ index e1cf1057e9dd6cc859621d791ec62bbb2bcff04b..0a622da1b4510922c60e36b587ec3851
this.insertInventoryEntityTracker = null;
this.insertInventoryEntityBox = null;
this.insertInventoryEntityFailedSearchTime = 0L;
@@ -1140,13 +1137,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -1143,13 +1140,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
private void invalidateExtractionData() {
if (this.level instanceof net.minecraft.server.level.ServerLevel) {
if (this.extractInventoryEntityTracker != null) {
Expand All @@ -81,7 +81,7 @@ index e1cf1057e9dd6cc859621d791ec62bbb2bcff04b..0a622da1b4510922c60e36b587ec3851
this.collectItemEntityTracker = null;
this.collectItemEntityBox = null;
this.collectItemEntityTrackerWasEmpty = false;
@@ -1282,7 +1279,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -1285,7 +1282,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
if (this.insertInventoryEntityTracker == null) {
this.initInsertInventoryTracker(world);
}
Expand All @@ -90,7 +90,7 @@ index e1cf1057e9dd6cc859621d791ec62bbb2bcff04b..0a622da1b4510922c60e36b587ec3851
this.insertInventoryEntityFailedSearchTime = this.tickedGameTime;
return null;
}
@@ -1347,7 +1344,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -1350,7 +1347,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
if (this.extractInventoryEntityTracker == null) {
this.initExtractInventoryTracker(level);
}
Expand All @@ -99,7 +99,7 @@ index e1cf1057e9dd6cc859621d791ec62bbb2bcff04b..0a622da1b4510922c60e36b587ec3851
this.extractInventoryEntityFailedSearchTime = this.tickedGameTime;
return null;
}
@@ -1467,7 +1464,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -1470,7 +1467,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
long modCount = net.caffeinemc.mods.lithium.common.hopper.InventoryHelper.getLithiumStackList(hopperBlockEntity).getModCount();

if ((hopperBlockEntity.collectItemEntityTrackerWasEmpty || hopperBlockEntity.myModCountAtLastItemCollect == modCount) &&
Expand Down