Paper/Spigot-Server-Patches/0418-Optimise-Chunk-getFluid.patch
Mariell 595734a57e
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#4659)
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

Bukkit Changes:
01e22e09 Misc maven build updates
746f5324 #556: Allow sending messages from specific UUIDs
92b99cde #501: Add PersistentDataHolder to Chunk

CraftBukkit Changes:
4ef13f94 Misc maven build updates
04639f5a #759: Allow sending messages from specific UUIDs
77c894a2 #672: Add PersistentDataHolder to Chunk

Spigot Changes:
57bbdd8e Rebuild patches

Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
2020-10-17 11:39:45 +01:00

63 lines
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Tue, 14 Jan 2020 14:59:08 -0800
Subject: [PATCH] Optimise Chunk#getFluid
Removing the try catch and generally reducing ops should make it
faster on its own, however removing the try catch makes it
easier to inline due to code size
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 98401f36f768f36f98007c52c998252e25b07d47..0bdd463a35d4b45fd6e50ab35046f1783600d3ee 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -389,17 +389,20 @@ public class Chunk implements IChunkAccess {
}
public Fluid a(int i, int j, int k) {
- try {
- if (j >= 0 && j >> 4 < this.sections.length) {
- ChunkSection chunksection = this.sections[j >> 4];
-
- if (!ChunkSection.a(chunksection)) {
- return chunksection.b(i & 15, j & 15, k & 15);
+ //try { // Paper - remove try catch
+ // Paper start - reduce the number of ops in this call
+ int index = j >> 4;
+ if (index >= 0 && index < this.sections.length) {
+ ChunkSection chunksection = this.sections[index];
+
+ if (chunksection != null) {
+ return chunksection.blockIds.a((j & 15) << 8 | (k & 15) << 4 | i & 15).getFluid();
}
+ // Paper end
}
return FluidTypes.EMPTY.h();
- } catch (Throwable throwable) {
+ /*} catch (Throwable throwable) { // Paper - remove try catch
CrashReport crashreport = CrashReport.a(throwable, "Getting fluid state");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Block being got");
@@ -408,6 +411,7 @@ public class Chunk implements IChunkAccess {
});
throw new ReportedException(crashreport);
}
+ */ // Paper - remove try catch
}
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/server/ChunkSection.java b/src/main/java/net/minecraft/server/ChunkSection.java
index 668942c629732b8d46b7f2646df8e7827baae240..39572cdce691a459cb9df0cc064fbf7bde83a99e 100644
--- a/src/main/java/net/minecraft/server/ChunkSection.java
+++ b/src/main/java/net/minecraft/server/ChunkSection.java
@@ -38,7 +38,7 @@ public class ChunkSection {
}
public Fluid b(int i, int j, int k) {
- return ((IBlockData) this.blockIds.a(i, j, k)).getFluid();
+ return ((IBlockData) this.blockIds.a(i, j, k)).getFluid(); // Paper - diff on change - we expect this to be effectively just getType(x, y, z).getFluid(). If this changes we need to check other patches that use IBlockData#getFluid.
}
public void a() {