2020-05-06 09:48:49 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2020-03-18 12:21:35 +00:00
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
2021-03-16 07:19:45 +00:00
diff --git a/src/main/java/net/minecraft/world/level/chunk/Chunk.java b/src/main/java/net/minecraft/world/level/chunk/Chunk.java
index 09d157bd2795b7e4374778cbd1e554de70f397bd..bd56cac7ce01942704d566c2cd8c1775fe643e25 100644
--- a/src/main/java/net/minecraft/world/level/chunk/Chunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/Chunk.java
@@ -424,17 +424,20 @@ public class Chunk implements IChunkAccess {
2020-03-18 12:21:35 +00:00
}
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");
2021-03-16 07:19:45 +00:00
@@ -443,6 +446,7 @@ public class Chunk implements IChunkAccess {
2020-03-18 12:21:35 +00:00
});
throw new ReportedException(crashreport);
}
+ */ // Paper - remove try catch
}
// CraftBukkit start
2021-03-16 07:19:45 +00:00
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/ChunkSection.java
2021-03-16 13:04:28 +00:00
index 4bc26a7a4ae91aac90c256758ec8868d83027c0c..973aa060d6964c7d470bc7aff89b879daf1df153 100644
2021-03-16 07:19:45 +00:00
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkSection.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkSection.java
2021-03-16 13:04:28 +00:00
@@ -45,7 +45,7 @@ public class ChunkSection {
2020-03-18 12:21:35 +00:00
}
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() {