3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 20:40:07 +01:00
Paper/Spigot-Server-Patches/0280-Avoid-Chunk-Lookups-for-Entity-TileEntity-Current-Ch.patch
Shane Freeder ea855e2b46 Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Developers!: You will need to clean up your work/Minecraft/1.13.2 folder
for this

Also, restore a patch that was dropped in the last upstream

Bukkit Changes:
279eeab3 Fix command description not being set
96e2bb18 Remove debug print from SyntheticEventTest

CraftBukkit Changes:
d3ed1516 Fix dangerously threaded beacons
217a293d Don't relocate joptsimple to allow --help to work.
1be05a21 Prepare for imminent Java 12 release
a49270b2 Mappings Update
5259d80c SPIGOT-4669: Fix PlayerTeleportEvent coordinates for relative teleports

Spigot Changes:
e6eb36f2 Rebuild patches
2019-03-20 01:55:16 +00:00

90 Zeilen
4.1 KiB
Diff

From d059aee7f3cf690c8173570c63b736fdf971921f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 4 Jul 2018 03:39:51 -0400
Subject: [PATCH] Avoid Chunk Lookups for Entity/TileEntity Current Chunk
In many places where we simply want the current chunk the entity
is in, instead of doing a hashmap lookup for it, we now have access
to the object directly on the Entity/TileEntity object we can directly grab.
Use that local value instead to reduce lookups in many hot places.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 3ca579e38..1c1f39524 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -723,6 +723,7 @@ public class Chunk implements IChunkAccess {
((HeightMap) this.heightMap.get(heightmap_type)).a(along);
}
+ public void removeEntity(Entity entity) { b(entity); } // Paper - OBFHELPER
public void b(Entity entity) {
this.a(entity, entity.chunkY);
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 08ad88c14..9befa890b 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1192,12 +1192,15 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
int j;
// Paper start - Set based removal lists
for (Entity e : this.g) {
+ /*
j = e.getChunkZ();
int k = e.getChunkX();
if (e.inChunk && this.isChunkLoaded(k, j, true)) {
this.getChunkAt(k, j).b(e);
- }
+ }*/
+ Chunk chunk = e.inChunk ? e.getCurrentChunk() : null;
+ if (chunk != null) chunk.removeEntity(e);
}
for (Entity e : this.g) {
@@ -1258,12 +1261,17 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
this.methodProfiler.exit();
this.methodProfiler.enter("remove");
if (entity.dead) {
+ // Paper start
+ /*
j = entity.chunkX;
int l = entity.chunkZ;
if (entity.inChunk && this.isChunkLoaded(j, l, true)) {
this.getChunkAt(j, l).b(entity);
- }
+ }*/
+ Chunk chunk = entity.inChunk ? entity.getCurrentChunk() : null;
+ if (chunk != null) chunk.removeEntity(entity);
+ // Paper end
guardEntityList = false; // Spigot
this.entityList.remove(this.tickPosition--); // CraftBukkit - Use field for loop variable
@@ -1308,7 +1316,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
BlockPosition blockposition = tileentity.getPosition();
// Paper start - Skip ticking in chunks scheduled for unload
- net.minecraft.server.Chunk chunk = this.getChunkIfLoaded(blockposition);
+ net.minecraft.server.Chunk chunk = tileentity.getCurrentChunk();
boolean shouldTick = chunk != null;
if(this.paperConfig.skipEntityTickingInChunksScheduledForUnload)
shouldTick = shouldTick && chunk.scheduledForUnload == null;
@@ -1344,8 +1352,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
tilesThisCycle--;
this.tileEntityListTick.remove(tileTickPosition--);
//this.tileEntityList.remove(tileentity); // Paper - remove unused list
- if (this.isLoaded(tileentity.getPosition())) {
- this.getChunkAtWorldCoords(tileentity.getPosition()).d(tileentity.getPosition());
+ // Paper start
+ net.minecraft.server.Chunk chunk = tileentity.getCurrentChunk();
+ if (chunk != null) {
+ chunk.removeTileEntity(tileentity.getPosition());
+ // Paper end
}
}
}
--
2.21.0