Improve inlining for some hot BlockBehavior and FluidState methods

This commit is contained in:
Spottedleaf
2020-07-06 20:46:50 -07:00
parent 2b90721a45
commit adf175d7ca
2 changed files with 62 additions and 2 deletions

View File

@@ -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<FluidState> 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<Property<?>, Comparable<?>> propertyMap, MapCodec<FluidState> 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) {