Optimize NavigationListener

This commit is contained in:
Aikar 2016-03-07 20:45:08 -06:00
parent d78781c869
commit b65586112b

View file

@ -0,0 +1,46 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 7 Mar 2016 20:41:27 -0500
Subject: [PATCH] Optimize NavigationListener
I believe Mojang intended to call the NavigationListener Block Update
method anytime a block is changed, but accidently added it for every
block physics event instead.
This code is massively ineffecient, and physics is so super hot, it
destroys server performance.
This patch moves the block update call to setTypeAndData instead of
on Physics.
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {
private int K;
public final Random random = new Random();
public WorldProvider worldProvider;
- protected NavigationListener t = new NavigationListener();
+ protected NavigationListener t = new NavigationListener(); public NavigationListener getNavListener() { return this.t; } // Paper
protected List<IWorldAccess> u;
protected IChunkProvider chunkProvider;
protected final IDataManager dataManager;
@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
// CraftBukkit end
- this.u = Lists.newArrayList(new IWorldAccess[] { this.t});
+ this.u = Lists.newArrayList(new IWorldAccess[] {}); // Paper
this.L = Calendar.getInstance();
this.scoreboard = new Scoreboard();
this.allowMonsters = true;
@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {
if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates
// Modularize client and physic updates
notifyAndUpdatePhysics(blockposition, chunk, iblockdata1, iblockdata, i);
+ this.getNavListener().a(this, blockposition, iblockdata1, iblockdata, i); // Paper
}
// CraftBukkit end
--