Paper/Spigot-Server-Patches/0589-Improve-inlinig-for-some-hot-IBlockData-methods.patch
2020-10-11 19:18:27 -04:00

102 lines
3.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <spottedleaf@spottedleaf.dev>
Date: Mon, 6 Jul 2020 20:46:50 -0700
Subject: [PATCH] Improve inlinig for some hot IBlockData methods
diff --git a/src/main/java/net/minecraft/server/BlockBase.java b/src/main/java/net/minecraft/server/BlockBase.java
index 505d40278d4472e0015a53af8e93bd81e5f09ac3..5131d2172d3cbd8a7254a6dd52e061888a17fb38 100644
--- a/src/main/java/net/minecraft/server/BlockBase.java
+++ b/src/main/java/net/minecraft/server/BlockBase.java
@@ -338,7 +338,14 @@ public abstract class BlockBase {
}
// Paper end
+ // Paper start
+ protected boolean isTicking;
+ protected Fluid fluid;
+ // Paper end
+
public void a() {
+ this.fluid = this.getBlock().d(this.p()); // Paper - moved from getFluid()
+ this.isTicking = this.getBlock().isTicking(this.p()); // Paper - moved from isTicking()
if (!this.getBlock().o()) {
this.a = new BlockBase.BlockData.Cache(this.p());
}
@@ -377,19 +384,19 @@ public abstract class BlockBase {
return this.getBlock().d(this.p(), iblockaccess, blockposition);
}
- public boolean d() {
+ public final boolean d() { // Paper
return this.a == null || this.a.c;
}
- public boolean e() {
+ public final boolean e() { // Paper
return this.e;
}
- public int f() {
+ public final int f() { // Paper
return this.b;
}
- public boolean isAir() {
+ public final boolean isAir() { // Paper
return this.f;
}
@@ -455,7 +462,7 @@ public abstract class BlockBase {
}
}
- public boolean l() {
+ public final boolean l() { // Paper
return this.k;
}
@@ -627,12 +634,12 @@ public abstract class BlockBase {
return this.getBlock().a(block);
}
- public Fluid getFluid() {
- return this.getBlock().d(this.p());
+ public final Fluid getFluid() { // Paper
+ return this.fluid; // Paper - moved into init
}
- public boolean isTicking() {
- return this.getBlock().isTicking(this.p());
+ public final boolean isTicking() { // Paper
+ return this.isTicking; // Paper - moved into init
}
public SoundEffectType getStepSound() {
diff --git a/src/main/java/net/minecraft/server/Fluid.java b/src/main/java/net/minecraft/server/Fluid.java
index 05fa52c0b12f159788ec3f2b769753b6bd29578c..ff2fb72f710dd5aa5126b1550c5ff11087d7e63e 100644
--- a/src/main/java/net/minecraft/server/Fluid.java
+++ b/src/main/java/net/minecraft/server/Fluid.java
@@ -9,8 +9,12 @@ public final class Fluid extends IBlockDataHolder<FluidType, Fluid> {
public static final Codec<Fluid> a = a((Codec) IRegistry.FLUID, FluidType::h).stable();
+ // Paper start
+ protected final boolean isEmpty;
+ // Paper end
public Fluid(FluidType fluidtype, ImmutableMap<IBlockState<?>, Comparable<?>> immutablemap, MapCodec<Fluid> mapcodec) {
super(fluidtype, immutablemap, mapcodec);
+ this.isEmpty = fluidtype.b(); // Paper - moved from isEmpty()
}
public FluidType getType() {
@@ -22,7 +26,7 @@ public final class Fluid extends IBlockDataHolder<FluidType, Fluid> {
}
public boolean isEmpty() {
- return this.getType().b();
+ return this.isEmpty; // Paper - moved into constructor
}
public float getHeight(IBlockAccess iblockaccess, BlockPosition blockposition) {