mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-15 14:13:56 +01:00
Improve inlining for some hot BlockBehavior and FluidState methods
This commit is contained in:
parent
2b90721a45
commit
adf175d7ca
2 changed files with 62 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
Loading…
Reference in a new issue