mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-09-28 23:27:42 +02:00
Update 0059-Optimize-Hopper-logic.patch
This commit is contained in:
parent
fd1ffb972b
commit
b08ee86c99
@ -1,12 +1,12 @@
|
||||
From de38322ff67af98006f66df5432393809f1f8c4a Mon Sep 17 00:00:00 2001
|
||||
From 5f2f5a3294c8d2e71c9459f0f88c272c477b6848 Mon Sep 17 00:00:00 2001
|
||||
From: tr7zw <tr7zw@live.de>
|
||||
Date: Fri, 26 Jun 2020 01:11:47 +0200
|
||||
Subject: [PATCH] Optimize Hopper logic
|
||||
|
||||
---
|
||||
.../net/minecraft/server/BlockHopper.java | 229 ++++++++++++++++++
|
||||
.../minecraft/server/TileEntityHopper.java | 34 ++-
|
||||
2 files changed, 260 insertions(+), 3 deletions(-)
|
||||
.../minecraft/server/TileEntityHopper.java | 36 ++-
|
||||
2 files changed, 261 insertions(+), 4 deletions(-)
|
||||
create mode 100644 src/main/java/net/minecraft/server/BlockHopper.java
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockHopper.java b/src/main/java/net/minecraft/server/BlockHopper.java
|
||||
@ -246,7 +246,7 @@ index 000000000..63e024e9d
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||
index c755faed4..5220e8673 100644
|
||||
index c755faed4..0e5ee991b 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||
@@ -2,6 +2,7 @@ package net.minecraft.server;
|
||||
@ -257,7 +257,17 @@ index c755faed4..5220e8673 100644
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
@@ -618,7 +619,23 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@@ -611,14 +612,28 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
|
||||
@Nullable
|
||||
private IInventory k() {
|
||||
+ if(this.cachedPush != null)return this.cachedPush;
|
||||
EnumDirection enumdirection = (EnumDirection) this.getBlock().get(BlockHopper.FACING);
|
||||
|
||||
- return b(this.getWorld(), this.position.shift(enumdirection));
|
||||
+ this.cachedPush = b(this.getWorld(), this.position.shift(enumdirection));
|
||||
+ return this.cachedPush;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static IInventory b(IHopper ihopper) {
|
||||
@ -266,14 +276,10 @@ index c755faed4..5220e8673 100644
|
||||
+ if(ihopper instanceof TileEntityHopper) {
|
||||
+ TileEntityHopper hopper = (TileEntityHopper) ihopper;
|
||||
+ if(hopper.cachedAbove != null) {
|
||||
+ if(hopper.cachedAbove.isPresent()) {
|
||||
+ return hopper.cachedAbove.get();
|
||||
+ }else {
|
||||
+ //should look for items?
|
||||
+ }
|
||||
+ return hopper.cachedAbove;
|
||||
+ }
|
||||
+ IInventory inv = a(ihopper.getWorld(), ihopper.z(), ihopper.A() + 1.0D, ihopper.B());
|
||||
+ hopper.cachedAbove = Optional.ofNullable(inv);
|
||||
+ hopper.cachedAbove = inv;
|
||||
+ return inv;
|
||||
+ }else {
|
||||
+ return a(ihopper.getWorld(), ihopper.z(), ihopper.A() + 1.0D, ihopper.B());
|
||||
@ -282,7 +288,7 @@ index c755faed4..5220e8673 100644
|
||||
}
|
||||
|
||||
public static List<EntityItem> c(IHopper ihopper) {
|
||||
@@ -658,7 +675,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@@ -658,7 +673,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -291,7 +297,7 @@ index c755faed4..5220e8673 100644
|
||||
if (object == null && (!optimizeEntities || !org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(block).isOccluding())) { // Paper
|
||||
List<Entity> list = world.getEntities((Entity) null, new AxisAlignedBB(d0 - 0.5D, d1 - 0.5D, d2 - 0.5D, d0 + 0.5D, d1 + 0.5D, d2 + 0.5D), IEntitySelector.d);
|
||||
|
||||
@@ -666,7 +683,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@@ -666,7 +681,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
object = (IInventory) list.get(world.random.nextInt(list.size()));
|
||||
}
|
||||
}
|
||||
@ -300,17 +306,19 @@ index c755faed4..5220e8673 100644
|
||||
return (IInventory) object;
|
||||
}
|
||||
|
||||
@@ -728,4 +745,15 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
@@ -728,4 +743,17 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
||||
protected Container createContainer(int i, PlayerInventory playerinventory) {
|
||||
return new ContainerHopper(i, playerinventory, this);
|
||||
}
|
||||
+
|
||||
+ // YAPFA start
|
||||
+
|
||||
+ private Optional<IInventory> cachedAbove = null;
|
||||
+ private IInventory cachedAbove = null;
|
||||
+ private IInventory cachedPush = null;
|
||||
+
|
||||
+ public void flushCaches() {
|
||||
+ cachedAbove = null;
|
||||
+ cachedPush = null;
|
||||
+ }
|
||||
+
|
||||
+ // YAPFA end
|
||||
|
Loading…
Reference in New Issue
Block a user