Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
Port Optimize-Hoppers.patch to 1.15 (#2765)
* port patch * fix hoppers eating items
Dieser Commit ist enthalten in:
Ursprung
26dfbc8046
Commit
3f5564f1bc
@ -1,4 +1,4 @@
|
|||||||
From bd7c380b8e4238b100012405cf46a02a0e05990d Mon Sep 17 00:00:00 2001
|
From c640bc9fc99c40e316e3a1725c2d4bf24adddeb8 Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Wed, 27 Apr 2016 22:09:52 -0400
|
Date: Wed, 27 Apr 2016 22:09:52 -0400
|
||||||
Subject: [PATCH] Optimize Hoppers
|
Subject: [PATCH] Optimize Hoppers
|
||||||
@ -11,12 +11,12 @@ Subject: [PATCH] Optimize Hoppers
|
|||||||
* Skip subsequent InventoryMoveItemEvents if a plugin does not use the item after first event fire for an iteration
|
* Skip subsequent InventoryMoveItemEvents if a plugin does not use the item after first event fire for an iteration
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
index 42d14fac2..80d66c647 100644
|
index 95be6cb2b..b309fdaba 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||||
@@ -397,4 +397,13 @@ public class PaperWorldConfig {
|
@@ -636,4 +636,13 @@ public class PaperWorldConfig {
|
||||||
this.armorStandTick = this.getBoolean("armor-stands-tick", this.armorStandTick);
|
private void entitiesTargetWithFollowRange() {
|
||||||
log("ArmorStand ticking is " + (this.armorStandTick ? "enabled" : "disabled") + " by default");
|
entitiesTargetWithFollowRange = getBoolean("entities-target-with-follow-range", entitiesTargetWithFollowRange);
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ public boolean cooldownHopperWhenFull = true;
|
+ public boolean cooldownHopperWhenFull = true;
|
||||||
@ -29,17 +29,18 @@ index 42d14fac2..80d66c647 100644
|
|||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
||||||
index 33d9cac4d..627fa465c 100644
|
index 1be4cd163..182633bca 100644
|
||||||
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
||||||
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
||||||
@@ -481,11 +481,12 @@ public final class ItemStack {
|
@@ -482,11 +482,12 @@ public final class ItemStack {
|
||||||
return this.getItem().a(this, entityhuman, entityliving, enumhand);
|
return this.getItem().a(this, entityhuman, entityliving, enumhand);
|
||||||
}
|
}
|
||||||
|
|
||||||
- public ItemStack cloneItemStack() {
|
- public ItemStack cloneItemStack() {
|
||||||
|
- if (this.isEmpty()) {
|
||||||
+ public ItemStack cloneItemStack() { return cloneItemStack(false); } // Paper
|
+ public ItemStack cloneItemStack() { return cloneItemStack(false); } // Paper
|
||||||
+ public ItemStack cloneItemStack(boolean origItem) { // Paper
|
+ public ItemStack cloneItemStack(boolean origItem) { // Paper
|
||||||
if (this.isEmpty()) {
|
+ if (!origItem && this.isEmpty()) { // Paper
|
||||||
return ItemStack.a;
|
return ItemStack.a;
|
||||||
} else {
|
} else {
|
||||||
- ItemStack itemstack = new ItemStack(this.getItem(), this.count);
|
- ItemStack itemstack = new ItemStack(this.getItem(), this.count);
|
||||||
@ -48,10 +49,10 @@ index 33d9cac4d..627fa465c 100644
|
|||||||
itemstack.d(this.C());
|
itemstack.d(this.C());
|
||||||
if (this.tag != null) {
|
if (this.tag != null) {
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
index dd2d8712e..206a4ad64 100644
|
index 664c48d68..edb3a6035 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -1168,6 +1168,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
@@ -1219,6 +1219,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
||||||
WorldServer worldserver = (WorldServer) iterator.next();
|
WorldServer worldserver = (WorldServer) iterator.next();
|
||||||
|
|
||||||
worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
|
worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
|
||||||
@ -80,10 +81,10 @@ index 958279249..a8e64dfda 100644
|
|||||||
this.world.b(this.position, this);
|
this.world.b(this.position, this);
|
||||||
if (!this.c.isAir()) {
|
if (!this.c.isAir()) {
|
||||||
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||||
index e08faf538..e7cf14d10 100644
|
index e08faf538..5dded0abe 100644
|
||||||
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||||
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||||
@@ -168,6 +168,158 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
@@ -168,6 +168,160 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +119,7 @@ index e08faf538..e7cf14d10 100644
|
|||||||
+ final int remaining = itemstack2.getCount();
|
+ final int remaining = itemstack2.getCount();
|
||||||
+ if (remaining != moved) {
|
+ if (remaining != moved) {
|
||||||
+ origItemStack = origItemStack.cloneItemStack(true);
|
+ origItemStack = origItemStack.cloneItemStack(true);
|
||||||
|
+ origItemStack.setCount(origCount);
|
||||||
+ if (!origItemStack.isEmpty()) {
|
+ if (!origItemStack.isEmpty()) {
|
||||||
+ origItemStack.setCount(origCount - moved + remaining);
|
+ origItemStack.setCount(origCount - moved + remaining);
|
||||||
+ }
|
+ }
|
||||||
@ -157,6 +159,7 @@ index e08faf538..e7cf14d10 100644
|
|||||||
+ final int remaining = itemstack2.getCount();
|
+ final int remaining = itemstack2.getCount();
|
||||||
+ if (remaining != moved) {
|
+ if (remaining != moved) {
|
||||||
+ origItemStack = origItemStack.cloneItemStack(true);
|
+ origItemStack = origItemStack.cloneItemStack(true);
|
||||||
|
+ origItemStack.setCount(origCount);
|
||||||
+ if (!origItemStack.isEmpty()) {
|
+ if (!origItemStack.isEmpty()) {
|
||||||
+ origItemStack.setCount(origCount - moved + remaining);
|
+ origItemStack.setCount(origCount - moved + remaining);
|
||||||
+ }
|
+ }
|
||||||
@ -242,7 +245,7 @@ index e08faf538..e7cf14d10 100644
|
|||||||
private boolean j() {
|
private boolean j() {
|
||||||
IInventory iinventory = this.k();
|
IInventory iinventory = this.k();
|
||||||
|
|
||||||
@@ -179,6 +331,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
@@ -179,6 +333,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||||
if (this.b(iinventory, enumdirection)) {
|
if (this.b(iinventory, enumdirection)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@ -250,7 +253,7 @@ index e08faf538..e7cf14d10 100644
|
|||||||
for (int i = 0; i < this.getSize(); ++i) {
|
for (int i = 0; i < this.getSize(); ++i) {
|
||||||
if (!this.getItem(i).isEmpty()) {
|
if (!this.getItem(i).isEmpty()) {
|
||||||
ItemStack itemstack = this.getItem(i).cloneItemStack();
|
ItemStack itemstack = this.getItem(i).cloneItemStack();
|
||||||
@@ -216,7 +369,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
@@ -216,7 +371,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +262,7 @@ index e08faf538..e7cf14d10 100644
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,6 +399,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
@@ -246,6 +401,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||||
EnumDirection enumdirection = EnumDirection.DOWN;
|
EnumDirection enumdirection = EnumDirection.DOWN;
|
||||||
|
|
||||||
return c(iinventory, enumdirection) ? false : a(iinventory, enumdirection).anyMatch((i) -> {
|
return c(iinventory, enumdirection) ? false : a(iinventory, enumdirection).anyMatch((i) -> {
|
||||||
@ -267,7 +270,7 @@ index e08faf538..e7cf14d10 100644
|
|||||||
return a(ihopper, iinventory, i, enumdirection);
|
return a(ihopper, iinventory, i, enumdirection);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -269,6 +423,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
@@ -269,6 +425,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||||
ItemStack itemstack = iinventory.getItem(i);
|
ItemStack itemstack = iinventory.getItem(i);
|
||||||
|
|
||||||
if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) {
|
if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) {
|
||||||
@ -275,7 +278,7 @@ index e08faf538..e7cf14d10 100644
|
|||||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||||
// ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null);
|
// ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null);
|
||||||
// CraftBukkit start - Call event on collection of items from inventories into the hopper
|
// CraftBukkit start - Call event on collection of items from inventories into the hopper
|
||||||
@@ -305,7 +460,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
@@ -305,7 +462,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||||
}
|
}
|
||||||
|
|
||||||
itemstack1.subtract(origCount - itemstack2.getCount()); // Spigot
|
itemstack1.subtract(origCount - itemstack2.getCount()); // Spigot
|
||||||
@ -284,7 +287,7 @@ index e08faf538..e7cf14d10 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -314,7 +469,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
@@ -314,7 +471,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||||
public static boolean a(IInventory iinventory, EntityItem entityitem) {
|
public static boolean a(IInventory iinventory, EntityItem entityitem) {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
@ -293,7 +296,7 @@ index e08faf538..e7cf14d10 100644
|
|||||||
entityitem.world.getServer().getPluginManager().callEvent(event);
|
entityitem.world.getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -368,7 +523,9 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
@@ -368,7 +525,9 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||||
boolean flag1 = iinventory1.isNotEmpty();
|
boolean flag1 = iinventory1.isNotEmpty();
|
||||||
|
|
||||||
if (itemstack1.isEmpty()) {
|
if (itemstack1.isEmpty()) {
|
||||||
@ -304,5 +307,5 @@ index e08faf538..e7cf14d10 100644
|
|||||||
flag = true;
|
flag = true;
|
||||||
} else if (a(itemstack1, itemstack)) {
|
} else if (a(itemstack1, itemstack)) {
|
||||||
--
|
--
|
||||||
2.24.1
|
2.22.0
|
||||||
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren