From adf175d7ca5add6ad40f461eee955e7cb7ec2622 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 6 Jul 2020 20:46:50 -0700 Subject: [PATCH] Improve inlining for some hot BlockBehavior and FluidState methods --- .../block/state/BlockBehaviour.java.patch | 41 ++++++++++++++++++- .../level/material/FluidState.java.patch | 23 +++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/world/level/material/FluidState.java.patch diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch index 1b17664e5..0715e1482 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -81,7 +81,7 @@ this.legacySolid = this.calculateSolid(); this.occlusionShape = this.canOcclude ? ((Block) this.owner).getOcclusionShape(this.asState()) : Shapes.empty(); -@@ -945,8 +969,8 @@ +@@ -945,19 +969,19 @@ return this.occlusionShape; } @@ -91,7 +91,30 @@ + return this.shapeExceedsCube; // Paper - moved into shape cache init } - public boolean useShapeForLightOcclusion() { +- public boolean useShapeForLightOcclusion() { ++ public final boolean useShapeForLightOcclusion() { // Paper - Perf: Final for inlining + return this.useShapeForLightOcclusion; + } + +- public int getLightEmission() { ++ public final int getLightEmission() { // Paper - Perf: Final for inlining + return this.lightEmission; + } + +- public boolean isAir() { ++ public final boolean isAir() { // Paper - Perf: Final for inlining + return this.isAir; + } + +@@ -1035,7 +1059,7 @@ + return this.solidRender; + } + +- public boolean canOcclude() { ++ public final boolean canOcclude() { // Paper - Perf: Final for inlining + return this.canOcclude; + } + @@ -1125,9 +1149,15 @@ } @@ -109,3 +132,17 @@ public void onRemove(Level world, BlockPos pos, BlockState state, boolean moved) { this.getBlock().onRemove(this.asState(), world, pos, state, moved); } +@@ -1250,11 +1280,11 @@ + return this.getBlock().builtInRegistryHolder().is(key); + } + +- public FluidState getFluidState() { ++ public final FluidState getFluidState() { // Paper - Perf: Final for inlining + return this.fluidState; + } + +- public boolean isRandomlyTicking() { ++ public final boolean isRandomlyTicking() { // Paper - Perf: Final for inlining + return this.isRandomlyTicking; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/FluidState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/FluidState.java.patch new file mode 100644 index 000000000..78b4ee0a6 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/material/FluidState.java.patch @@ -0,0 +1,23 @@ +--- a/net/minecraft/world/level/material/FluidState.java ++++ b/net/minecraft/world/level/material/FluidState.java +@@ -26,9 +26,11 @@ + public static final Codec CODEC = codec(BuiltInRegistries.FLUID.byNameCodec(), Fluid::defaultFluidState).stable(); + public static final int AMOUNT_MAX = 9; + public static final int AMOUNT_FULL = 8; ++ protected final boolean isEmpty; // Paper - Perf: moved from isEmpty() + + public FluidState(Fluid fluid, Reference2ObjectArrayMap, Comparable> propertyMap, MapCodec codec) { + super(fluid, propertyMap, codec); ++ this.isEmpty = fluid.isEmpty(); // Paper - Perf: moved from isEmpty() + } + + public Fluid getType() { +@@ -44,7 +46,7 @@ + } + + public boolean isEmpty() { +- return this.getType().isEmpty(); ++ return this.isEmpty; // Paper - Perf: moved into constructor + } + + public float getHeight(BlockGetter world, BlockPos pos) {