diff --git a/leaf-server/minecraft-patches/features/0287-optimize-PalettedContainer-get.patch b/leaf-server/minecraft-patches/features/0287-optimize-PalettedContainer-get.patch index cbf9168e..894519be 100644 --- a/leaf-server/minecraft-patches/features/0287-optimize-PalettedContainer-get.patch +++ b/leaf-server/minecraft-patches/features/0287-optimize-PalettedContainer-get.patch @@ -5,7 +5,7 @@ Subject: [PATCH] optimize PalettedContainer#get diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index 49220967392331dd9928a539da6e6052b007e318..9319ccc4ee8e44ea8c1f32e623f2d3c7ceed1f4f 100644 +index 49220967392331dd9928a539da6e6052b007e318..dd26ee1c377709d77709d449e98694d047afaa09 100644 --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java @@ -48,6 +48,18 @@ public class PalettedContainer implements PaletteResize, PalettedContainer @@ -41,7 +41,7 @@ index 49220967392331dd9928a539da6e6052b007e318..9319ccc4ee8e44ea8c1f32e623f2d3c7 public T get(int index) { // Paper - public // Paper start - optimise palette reads - final PalettedContainer.Data data = this.data; -+ final PalettedContainer.Data data = (PalettedContainer.Data) DATA_HANDLE.getAcquire(this); // Leaf - optimize get chunk ++ final PalettedContainer.Data data = (PalettedContainer.Data) DATA_HANDLE.getAcquire(this); // Leaf - optimize PalettedContainer#get return this.readPalette(data, data.storage.get(index)); // Paper end - optimise palette reads } diff --git a/leaf-server/minecraft-patches/features/0294-optimize-isStateClimbable.patch b/leaf-server/minecraft-patches/features/0294-optimize-isStateClimbable.patch index f4a248a1..2f37a85c 100644 --- a/leaf-server/minecraft-patches/features/0294-optimize-isStateClimbable.patch +++ b/leaf-server/minecraft-patches/features/0294-optimize-isStateClimbable.patch @@ -5,16 +5,15 @@ Subject: [PATCH] optimize isStateClimbable diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 0bd4bc2d3d3edf6f7ea5e41d4049b2e0a3b3151e..3aec52d72cd5ffd2ef61b1f6c37c6b7f1203d06f 100644 +index 0bd4bc2d3d3edf6f7ea5e41d4049b2e0a3b3151e..bc02ce9093adb0ec09252ce00f60dd84335cca70 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -1376,7 +1376,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1376,7 +1376,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } private boolean isStateClimbable(BlockState state) { - return state.is(BlockTags.CLIMBABLE) || state.is(Blocks.POWDER_SNOW); -+ final int flags = state.tagFlag; -+ return (flags & (org.dreeam.leaf.util.BlockMasks.CLIMBABLE_TAG | org.dreeam.leaf.util.BlockMasks.POWDER_SNOW_CL)) != 0; ++ return (state.tagFlag & org.dreeam.leaf.util.BlockMasks.IS_STATE_CLIMBABLE) != 0; // Leaf - optimize isStateClimbable } private boolean vibrationAndSoundEffectsFromBlock(BlockPos pos, BlockState state, boolean playStepSound, boolean broadcastGameEvent, Vec3 entityPos) { diff --git a/leaf-server/minecraft-patches/features/0295-optimize-getOnPos.patch b/leaf-server/minecraft-patches/features/0295-optimize-getOnPos.patch index e497fc8a..54b0d506 100644 --- a/leaf-server/minecraft-patches/features/0295-optimize-getOnPos.patch +++ b/leaf-server/minecraft-patches/features/0295-optimize-getOnPos.patch @@ -5,15 +5,15 @@ Subject: [PATCH] optimize getOnPos diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 3aec52d72cd5ffd2ef61b1f6c37c6b7f1203d06f..8c01317e1aa5cc588eb2d9e4d47de1da93d5146a 100644 +index bc02ce9093adb0ec09252ce00f60dd84335cca70..bb16f3ebffcafcb11d3112e03f5767ac71b359f6 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -895,6 +895,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // CraftBukkit end public void baseTick() { -+ this.leaf$onBlockState = null; // Leaf -+ this.leaf$cacheOnBlock = true; // Leaf ++ this.leaf$onBlockState = null; // Leaf - optimize getOnPos ++ this.leaf$cacheOnBlock = true; // Leaf - optimize getOnPos if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups this.inBlockState = null; if (this.isPassenger() && this.getVehicle().isRemoved()) { @@ -21,7 +21,7 @@ index 3aec52d72cd5ffd2ef61b1f6c37c6b7f1203d06f..8c01317e1aa5cc588eb2d9e4d47de1da if (this.level() instanceof ServerLevel serverLevelx && this instanceof Leashable) { Leashable.tickLeash(serverLevelx, (Entity & Leashable)this); } -+ this.leaf$cacheOnBlock = false; // Leaf ++ this.leaf$cacheOnBlock = false; // Leaf - optimize getOnPos } public void setSharedFlagOnFire(boolean isOnFire) { @@ -30,20 +30,20 @@ index 3aec52d72cd5ffd2ef61b1f6c37c6b7f1203d06f..8c01317e1aa5cc588eb2d9e4d47de1da Optional optional = this.level.findSupportingBlock(this, aabb); if (optional.isPresent() || this.onGroundNoBlocks) { - this.mainSupportingBlockPos = optional; -+ // Leaf start ++ // Leaf start - optimize getOnPos + if (mainSupportingBlockPos.isEmpty() || optional.isEmpty() || !mainSupportingBlockPos.get().equals(optional.get())) { + this.mainSupportingBlockPos = optional; + } -+ // Leaf end ++ // Leaf end - optimize getOnPos } else if (movement != null) { AABB aabb1 = aabb.move(-movement.x, 0.0, -movement.z); optional = this.level.findSupportingBlock(this, aabb1); - this.mainSupportingBlockPos = optional; -+ // Leaf start ++ // Leaf start - optimize getOnPos + if (mainSupportingBlockPos.isEmpty() || optional.isEmpty() || !mainSupportingBlockPos.get().equals(optional.get())) { + this.mainSupportingBlockPos = optional; + } -+ // Leaf end ++ // Leaf end - optimize getOnPos } this.onGroundNoBlocks = optional.isEmpty(); @@ -53,8 +53,8 @@ index 3aec52d72cd5ffd2ef61b1f6c37c6b7f1203d06f..8c01317e1aa5cc588eb2d9e4d47de1da - BlockPos onPosLegacy = this.getOnPosLegacy(); - BlockState blockState = this.level().getBlockState(onPosLegacy); -+ BlockState blockState = this.leaf$getOnBlockLegacy(); // Leaf -+ BlockPos onPosLegacy = this.leaf$getOnBlockPos(); // Leaf ++ BlockState blockState = this.leaf$getOnBlockLegacy(); // Leaf - optimize getOnPos ++ BlockPos onPosLegacy = this.leaf$getOnBlockPos(); // Leaf - optimize getOnPos if (this.isLocalInstanceAuthoritative()) { this.checkFallDamage(vec3.y, this.onGround(), blockState, onPosLegacy); } @@ -65,8 +65,8 @@ index 3aec52d72cd5ffd2ef61b1f6c37c6b7f1203d06f..8c01317e1aa5cc588eb2d9e4d47de1da - BlockPos onPos = this.getOnPos(); - BlockState blockState = this.level.getBlockStateIfLoadedUnchecked(onPos.getX(), onPos.getY(), onPos.getZ()); - if (blockState == null) { blockState = this.level.getBlockState(onPos); } -+ BlockState blockState = this.leaf$getOnBlock0(); // Leaf -+ BlockPos onPos = this.leaf$getOnBlockPos(); // Leaf ++ BlockState blockState = this.leaf$getOnBlock0(); // Leaf - optimize getOnPos ++ BlockPos onPos = this.leaf$getOnBlockPos(); // Leaf - optimize getOnPos boolean isStateClimbable = this.isStateClimbable(blockState); this.moveDist += isStateClimbable ? f1 : f2; this.flyDist += f1; @@ -76,45 +76,45 @@ index 3aec52d72cd5ffd2ef61b1f6c37c6b7f1203d06f..8c01317e1aa5cc588eb2d9e4d47de1da if (this.onGround()) { - BlockPos onPosLegacy = this.getOnPosLegacy(); - BlockState blockState = this.level().getBlockState(onPosLegacy); -+ BlockState blockState = this.leaf$getOnBlockLegacy(); // Leaf -+ BlockPos onPosLegacy = this.leaf$getOnBlockPos(); // Leaf ++ BlockState blockState = this.leaf$getOnBlockLegacy(); // Leaf - optimize getOnPos ++ BlockPos onPosLegacy = this.leaf$getOnBlockPos(); // Leaf - optimize getOnPos blockState.getBlock().stepOn(this.level(), onPosLegacy, blockState, this); } -@@ -1443,34 +1453,124 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1442,34 +1452,124 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return this.getOnPos(0.2F); } -+ // Leaf start ++ // Leaf start - optimize getOnPos + @Deprecated + public BlockState leaf$getOnBlockLegacy() { + return this.leaf$getOnBlock(0.2F); + } -+ // Leaf end ++ // Leaf end - optimize getOnPos + public BlockPos getBlockPosBelowThatAffectsMyMovement() { return this.getOnPos(0.500001F); } -+ // Leaf start ++ // Leaf start - optimize getOnPos + public net.minecraft.world.level.block.state.BlockState leaf$getBlockBelow() { + return this.leaf$getOnBlock(0.500001F); + } -+ // Leaf end ++ // Leaf end - optimize getOnPos + public BlockPos getOnPos() { return this.getOnPos(1.0E-5F); } -+ // Leaf start ++ // Leaf start - optimize getOnPos + public BlockState leaf$getOnBlock0() { + return this.leaf$getOnBlock(1.0E-5F); + } -+ // Leaf end ++ // Leaf end - optimize getOnPos + protected BlockPos getOnPos(float yOffset) { - if (this.mainSupportingBlockPos.isPresent() && this.level().getChunkIfLoadedImmediately(this.mainSupportingBlockPos.get()) != null) { // Paper - ensure no loads -+ // Leaf start - optimize get chunk ++ // Leaf start - optimize getOnPos + if (this.mainSupportingBlockPos.isPresent()) { BlockPos blockPos = this.mainSupportingBlockPos.get(); + int x = blockPos.getX(); @@ -145,10 +145,10 @@ index 3aec52d72cd5ffd2ef61b1f6c37c6b7f1203d06f..8c01317e1aa5cc588eb2d9e4d47de1da int floor2 = Mth.floor(this.position.z); return new BlockPos(floor, floor1, floor2); } -+ // Leaf end - optimize get chunk ++ // Leaf end - optimize getOnPos + } + -+ // Leaf start ++ // Leaf start - optimize getOnPos + @Nullable private BlockState leaf$onBlockState = null; + private BlockPos leaf$onBlockPos = BlockPos.ZERO; + public boolean leaf$cacheOnBlock = false; @@ -210,59 +210,59 @@ index 3aec52d72cd5ffd2ef61b1f6c37c6b7f1203d06f..8c01317e1aa5cc588eb2d9e4d47de1da + return leaf$onBlockState; + } } -+ // Leaf end ++ // Leaf end - optimize getOnPos protected float getBlockJumpFactor() { float jumpFactor = this.level().getBlockState(this.blockPosition()).getBlock().getJumpFactor(); -@@ -1482,7 +1582,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1481,7 +1581,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess BlockState blockState = this.level().getBlockState(this.blockPosition()); float speedFactor = blockState.getBlock().getSpeedFactor(); if (!blockState.is(Blocks.WATER) && !blockState.is(Blocks.BUBBLE_COLUMN)) { - return speedFactor == 1.0 ? this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getSpeedFactor() : speedFactor; -+ return speedFactor == 1.0 ? this.leaf$getBlockBelow().getBlock().getSpeedFactor() : speedFactor; // Leaf ++ return speedFactor == 1.0 ? this.leaf$getBlockBelow().getBlock().getSpeedFactor() : speedFactor; // Leaf - optimize getOnPos } else { return speedFactor; } -@@ -2104,7 +2204,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -2103,7 +2203,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @Deprecated protected BlockState getBlockStateOnLegacy() { - return this.level().getBlockState(this.getOnPosLegacy()); -+ return this.leaf$getOnBlockLegacy(); // Leaf ++ return this.leaf$getOnBlockLegacy(); // Leaf - optimize getOnPos } public BlockState getBlockStateOn() { -@@ -2116,8 +2216,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -2115,8 +2215,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } protected void spawnSprintParticle() { - BlockPos onPosLegacy = this.getOnPosLegacy(); - BlockState blockState = this.level().getBlockState(onPosLegacy); -+ BlockState blockState = this.leaf$getOnBlockLegacy(); // Leaf -+ BlockPos onPosLegacy = this.leaf$getOnBlockPos(); // Leaf ++ BlockState blockState = this.leaf$getOnBlockLegacy(); // Leaf - optimize getOnPos ++ BlockPos onPosLegacy = this.leaf$getOnBlockPos(); // Leaf - optimize getOnPos if (blockState.getRenderShape() != RenderShape.INVISIBLE) { Vec3 deltaMovement = this.getDeltaMovement(); BlockPos blockPos = this.blockPosition(); diff --git a/net/minecraft/world/entity/ExperienceOrb.java b/net/minecraft/world/entity/ExperienceOrb.java -index 3ee788b172240ccf38cb31385dff13364ccc4142..f61ccef92c46b13bbe53df1fca8a3b4798b006e4 100644 +index 3ee788b172240ccf38cb31385dff13364ccc4142..d88fc291f3c6ea7dd8293d39a435607937d877bc 100644 --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java @@ -243,6 +243,13 @@ public class ExperienceOrb extends Entity { return this.getOnPos(0.999999F); } -+ // Leaf start ++ // Leaf start - optimize getOnPos + @Override + public net.minecraft.world.level.block.state.BlockState leaf$getBlockBelow() { + return this.leaf$getOnBlock(0.999999F); + } -+ // Leaf end ++ // Leaf end - optimize getOnPos + private void scanForMerges() { if (this.level() instanceof ServerLevel) { for (ExperienceOrb experienceOrb : this.level() diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index f0a0a19e2adff03e73e75c3db831dbf74ebf3861..eb408f9318ce406b22c6dbb575f08329fb286ee0 100644 +index f0a0a19e2adff03e73e75c3db831dbf74ebf3861..b8665f74bc5592b0022636e62482e21c84692d39 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -3087,7 +3087,11 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @@ -270,11 +270,11 @@ index f0a0a19e2adff03e73e75c3db831dbf74ebf3861..eb408f9318ce406b22c6dbb575f08329 public void travel(Vec3 travelVector) { - FluidState fluidState = this.level().getFluidState(this.blockPosition()); -+ // Leaf start ++ // Leaf start - optimize getOnPos + BlockPos blockPos = this.blockPosition(); + FluidState fluidState = this.level().getFluidStateIfLoadedUnchecked(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + if (fluidState == null) { this.level().getFluidState(blockPos); } -+ // Leaf end ++ // Leaf end - optimize getOnPos if ((this.isInWater() || this.isInLava()) && this.isAffectedByFluids() && !this.canStandOnFluid(fluidState)) { this.travelInFluid(travelVector); } else if (this.isFallFlying()) { @@ -322,7 +322,7 @@ index f0a0a19e2adff03e73e75c3db831dbf74ebf3861..eb408f9318ce406b22c6dbb575f08329 if (this.level().isClientSide()) { this.calculateEntityAnimation(this instanceof FlyingAnimal); diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index 52314a8fe4188689431f9a1261226859b967f5f1..e93cf31ddb1affcfcdaab380a6614c118a96eaa1 100644 +index 52314a8fe4188689431f9a1261226859b967f5f1..b4f72a15b117e1e5438f509a2d7392aa14886316 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java @@ -204,7 +204,7 @@ public class ItemEntity extends Entity implements TraceableEntity { @@ -338,12 +338,12 @@ index 52314a8fe4188689431f9a1261226859b967f5f1..e93cf31ddb1affcfcdaab380a6614c11 return this.getOnPos(0.999999F); } -+ // Leaf start ++ // Leaf start - optimize getOnPos + @Override + public net.minecraft.world.level.block.state.BlockState leaf$getBlockBelow() { + return this.leaf$getOnBlock(0.999999F); + } -+ // Leaf end ++ // Leaf end - optimize getOnPos + private void setUnderwaterMovement() { this.setFluidMovement(0.99F); diff --git a/leaf-server/minecraft-patches/features/0296-optimize-get-eye-block-position.patch b/leaf-server/minecraft-patches/features/0296-optimize-get-eye-block-position.patch index 7712d199..f498762b 100644 --- a/leaf-server/minecraft-patches/features/0296-optimize-get-eye-block-position.patch +++ b/leaf-server/minecraft-patches/features/0296-optimize-get-eye-block-position.patch @@ -5,7 +5,7 @@ Subject: [PATCH] optimize get eye block position diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 8c01317e1aa5cc588eb2d9e4d47de1da93d5146a..11a0fcf040053f9e84db21b3890cdfdc330755f0 100644 +index bb16f3ebffcafcb11d3112e03f5767ac71b359f6..22b7b1bd62f730a760ce0cf0a2ddb701324e3c3e 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -553,20 +553,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -56,7 +56,7 @@ index 8c01317e1aa5cc588eb2d9e4d47de1da93d5146a..11a0fcf040053f9e84db21b3890cdfdc // Purpur end - copied from Mob - API for any mob to burn daylight // Leaf end - Fix Pufferfish and Purpur patches -@@ -2152,8 +2157,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -2151,8 +2156,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess && abstractBoat.getBoundingBox().maxY >= eyeY && abstractBoat.getBoundingBox().minY <= eyeY )) { @@ -68,7 +68,7 @@ index 8c01317e1aa5cc588eb2d9e4d47de1da93d5146a..11a0fcf040053f9e84db21b3890cdfdc double d = blockPos.getY() + fluidState.getHeight(this.level(), blockPos); if (d > eyeY) { // Leaf start - Optimize isEyeInFluid -@@ -2281,20 +2287,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -2280,20 +2286,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @Deprecated public float getLightLevelDependentMagicValue() { @@ -91,7 +91,7 @@ index 8c01317e1aa5cc588eb2d9e4d47de1da93d5146a..11a0fcf040053f9e84db21b3890cdfdc public void absSnapTo(double x, double y, double z, float yRot, float xRot) { this.absSnapTo(x, y, z); -@@ -4532,6 +4528,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4531,6 +4527,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess EntityDimensions dimensions = this.getDimensions(pose); this.dimensions = dimensions; this.eyeHeight = dimensions.eyeHeight(); @@ -99,7 +99,7 @@ index 8c01317e1aa5cc588eb2d9e4d47de1da93d5146a..11a0fcf040053f9e84db21b3890cdfdc } public void refreshDimensions() { -@@ -4540,6 +4537,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4539,6 +4536,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess EntityDimensions dimensions = this.getDimensions(pose); this.dimensions = dimensions; this.eyeHeight = dimensions.eyeHeight(); @@ -108,7 +108,7 @@ index 8c01317e1aa5cc588eb2d9e4d47de1da93d5146a..11a0fcf040053f9e84db21b3890cdfdc boolean flag = dimensions.width() <= 4.0F && dimensions.height() <= 4.0F; if (!this.level.isClientSide diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index eb408f9318ce406b22c6dbb575f08329fb286ee0..04e7bcf4cc004b4323a23dadf5d9d347ba5aa881 100644 +index b8665f74bc5592b0022636e62482e21c84692d39..dc66b2c59984ce62b1d3c4a97c769771229fb4f8 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -464,7 +464,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin diff --git a/leaf-server/minecraft-patches/features/0297-optimize-updateFluidHeightAndDoFluidPushing.patch b/leaf-server/minecraft-patches/features/0297-optimize-updateFluidHeightAndDoFluidPushing.patch index 77796944..aa601dda 100644 --- a/leaf-server/minecraft-patches/features/0297-optimize-updateFluidHeightAndDoFluidPushing.patch +++ b/leaf-server/minecraft-patches/features/0297-optimize-updateFluidHeightAndDoFluidPushing.patch @@ -5,10 +5,10 @@ Subject: [PATCH] optimize updateFluidHeightAndDoFluidPushing diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 11a0fcf040053f9e84db21b3890cdfdc330755f0..ae8154b4dea055c219797f00f357e56c74bcdace 100644 +index 22b7b1bd62f730a760ce0cf0a2ddb701324e3c3e..2d3998b547a5593703788f7a532f960f6054b7c9 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -4933,12 +4933,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4932,12 +4932,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess final int minChunkZ = minBlockZ >> 4; final int maxChunkZ = maxBlockZ >> 4; @@ -23,7 +23,7 @@ index 11a0fcf040053f9e84db21b3890cdfdc330755f0..ae8154b4dea055c219797f00f357e56c if (chunk == null) continue; final net.minecraft.world.level.chunk.LevelChunkSection[] sections = chunk.getSections(); // Leaf end - Prevent double chunk retrieving in entity fluid pushing check and fluid height updating -@@ -4950,7 +4950,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4949,7 +4949,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess continue; } final net.minecraft.world.level.chunk.LevelChunkSection section = sections[sectionIdx]; @@ -32,7 +32,7 @@ index 11a0fcf040053f9e84db21b3890cdfdc330755f0..ae8154b4dea055c219797f00f357e56c // empty continue; } -@@ -5007,7 +5007,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -5006,7 +5006,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.fluidHeight.put(fluid, maxHeightDiff); diff --git a/leaf-server/minecraft-patches/features/0298-optimize-checkInsideBlocks.patch b/leaf-server/minecraft-patches/features/0298-optimize-checkInsideBlocks.patch index b99db894..bd4da4a7 100644 --- a/leaf-server/minecraft-patches/features/0298-optimize-checkInsideBlocks.patch +++ b/leaf-server/minecraft-patches/features/0298-optimize-checkInsideBlocks.patch @@ -5,10 +5,10 @@ Subject: [PATCH] optimize checkInsideBlocks diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index ae8154b4dea055c219797f00f357e56c74bcdace..8a43dfcb5b8c041a80bd01611bdc8865a754e8cd 100644 +index 2d3998b547a5593703788f7a532f960f6054b7c9..0804d3dc5262350a194c5e6d86c313364b6fba76 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -1812,72 +1812,57 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1811,72 +1811,57 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess private void checkInsideBlocks(Vec3 vec3, Vec3 vec31, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet set) { final Level level = this.level(); AABB aabb = this.getBoundingBox().move(vec31.subtract(this.position())).deflate(1.0E-5F); diff --git a/leaf-server/minecraft-patches/features/0299-Replace-fluid-height-map.patch b/leaf-server/minecraft-patches/features/0299-replace-entity-fluid-height-map.patch similarity index 86% rename from leaf-server/minecraft-patches/features/0299-Replace-fluid-height-map.patch rename to leaf-server/minecraft-patches/features/0299-replace-entity-fluid-height-map.patch index 421d35a5..18fd8245 100644 --- a/leaf-server/minecraft-patches/features/0299-Replace-fluid-height-map.patch +++ b/leaf-server/minecraft-patches/features/0299-replace-entity-fluid-height-map.patch @@ -1,11 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: hayanesuru Date: Sun, 10 Aug 2025 16:14:07 +0900 -Subject: [PATCH] Replace fluid height map +Subject: [PATCH] replace entity fluid height map diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 8a43dfcb5b8c041a80bd01611bdc8865a754e8cd..7dda8c5db2bbbfe04db07b1a053489b4d19f3f09 100644 +index 0804d3dc5262350a194c5e6d86c313364b6fba76..fc1175ae9bf5b59be2575a4e560bb558cbf007f4 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -286,7 +286,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess diff --git a/leaf-server/minecraft-patches/features/0300-optimize-collision-shape.patch b/leaf-server/minecraft-patches/features/0300-optimize-collision-shape.patch index 5a26b822..b9e229f6 100644 --- a/leaf-server/minecraft-patches/features/0300-optimize-collision-shape.patch +++ b/leaf-server/minecraft-patches/features/0300-optimize-collision-shape.patch @@ -5,20 +5,20 @@ Subject: [PATCH] optimize collision shape diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index 9caac78f0dbadc838753e2db7b757b70cea2fae8..782b5e58bc7a528d896a5b182476ba6fa3f8abc4 100644 +index 9caac78f0dbadc838753e2db7b757b70cea2fae8..ef0849eb69deee974a8dd5ada628b469822755e5 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java @@ -623,6 +623,13 @@ public abstract class BlockBehaviour implements FeatureElement { this.emptyConstantCollisionShape = this.constantCollisionShape != null && this.constantCollisionShape.isEmpty(); // init caches initCaches(collisionShape, true); -+ // Leaf start ++ // Leaf start - optimize collision shape + switch (getBlock()) { + case net.minecraft.world.level.block.FireBlock fireBlock -> {} + case net.minecraft.world.level.block.LiquidBlock liquidBlock -> {} + default -> this.constantCollisionShape = collisionShape; + } -+ // Leaf end ++ // Leaf end - optimize collision shape if (this.constantCollisionShape != null) { initCaches(this.constantCollisionShape, true); } diff --git a/leaf-server/minecraft-patches/features/0301-cache-collision-list.patch b/leaf-server/minecraft-patches/features/0301-cache-collision-list.patch index 36825f4a..5cb11a50 100644 --- a/leaf-server/minecraft-patches/features/0301-cache-collision-list.patch +++ b/leaf-server/minecraft-patches/features/0301-cache-collision-list.patch @@ -5,78 +5,78 @@ Subject: [PATCH] cache collision list diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index b94f2122da885fe94bd60c7914421968e6a2f3fa..57e123c65f48690a5d6375e4dfd1465c531d4480 100644 +index b94f2122da885fe94bd60c7914421968e6a2f3fa..5178290d060dd8a72f0e6cb77f77d19683a866d0 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -1095,6 +1095,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final org.dreeam.leaf.world.DespawnMap despawnMap = new org.dreeam.leaf.world.DespawnMap(paperConfig()); // Leaf - optimize despawn public final org.dreeam.leaf.world.NatureSpawnChunkMap natureSpawnChunkMap = new org.dreeam.leaf.world.NatureSpawnChunkMap(); // Leaf - optimize mob spawning public final org.dreeam.leaf.world.RandomTickSystem randomTickSystem = new org.dreeam.leaf.world.RandomTickSystem(); // Leaf - optimize random tick -+ public final org.dreeam.leaf.world.EntityCollisionCache entityCollisionCache = new org.dreeam.leaf.world.EntityCollisionCache(); // Leaf ++ public final org.dreeam.leaf.world.EntityCollisionCache entityCollisionCache = new org.dreeam.leaf.world.EntityCollisionCache(); // Leaf - cache collision list + public void tickChunk(LevelChunk chunk, int randomTickSpeed) { final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = this.simpleRandom; // Paper - optimise random ticking // Leaf - Faster random generator - upcasting ChunkPos pos = chunk.getPos(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 7dda8c5db2bbbfe04db07b1a053489b4d19f3f09..2b0c5d5920a3df8c4d6076c45d3191976f7abfec 100644 +index fc1175ae9bf5b59be2575a4e560bb558cbf007f4..46724762116945d9eb8d1692657fe5ef4d7f912b 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -1641,8 +1641,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1640,8 +1640,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess final AABB currentBox = this.getBoundingBox(); - final List potentialCollisionsVoxel = new ArrayList<>(); - final List potentialCollisionsBB = new ArrayList<>(); -+ // final List potentialCollisionsVoxel = new ArrayList<>(); // Leaf -+ // final List potentialCollisionsBB = new ArrayList<>(); // Leaf ++ // final List potentialCollisionsVoxel = new ArrayList<>(); // Leaf - cache collision list ++ // final List potentialCollisionsBB = new ArrayList<>(); // Leaf - cache collision list final AABB initialCollisionBox; if (xZero & zZero) { -@@ -1654,17 +1654,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1653,17 +1653,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess initialCollisionBox = currentBox.expandTowards(movement); } - final List entityAABBs = new ArrayList<>(); -+ org.dreeam.leaf.world.EntityCollisionCache entityCollisionCache = ((ServerLevel) this.level).entityCollisionCache; // Leaf ++ org.dreeam.leaf.world.EntityCollisionCache entityCollisionCache = ((ServerLevel) this.level).entityCollisionCache; // Leaf - cache collision list ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getEntityHardCollisions( - this.level, (Entity)(Object)this, initialCollisionBox, entityAABBs, 0, null -+ this.level, (Entity)(Object)this, initialCollisionBox, entityCollisionCache.entityAABBs(), 0, null // Leaf ++ this.level, (Entity)(Object)this, initialCollisionBox, entityCollisionCache.entityAABBs(), 0, null // Leaf - cache collision list ); ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisionsForBlocksOrWorldBorder( - this.level, (Entity)(Object)this, initialCollisionBox, potentialCollisionsVoxel, potentialCollisionsBB, -+ this.level, (Entity)(Object)this, initialCollisionBox, entityCollisionCache.potentialCollisionsVoxel(), entityCollisionCache.potentialCollisionsBB(), ++ this.level, (Entity)(Object)this, initialCollisionBox, entityCollisionCache.potentialCollisionsVoxel(), entityCollisionCache.potentialCollisionsBB(), // Leaf - cache collision list ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER, null ); - potentialCollisionsBB.addAll(entityAABBs); - final Vec3 collided = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currentBox, potentialCollisionsVoxel, potentialCollisionsBB); -+ entityCollisionCache.potentialCollisionsBB().addAll(entityCollisionCache.entityAABBs()); // Leaf -+ final Vec3 collided = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currentBox, entityCollisionCache.potentialCollisionsVoxel(), entityCollisionCache.potentialCollisionsBB()); // Leaf ++ entityCollisionCache.potentialCollisionsBB().addAll(entityCollisionCache.entityAABBs()); // Leaf - cache collision list ++ final Vec3 collided = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currentBox, entityCollisionCache.potentialCollisionsVoxel(), entityCollisionCache.potentialCollisionsBB()); // Leaf - cache collision list final boolean collidedX = collided.x != movement.x; final boolean collidedY = collided.y != movement.y; -@@ -1675,6 +1675,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1674,6 +1674,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess final double stepHeight; if ((!collidedDownwards && !this.onGround) || (!collidedX && !collidedZ) || (stepHeight = (double)this.maxUpStep()) <= 0.0) { -+ entityCollisionCache.clear(); // Leaf ++ entityCollisionCache.clear(); // Leaf - cache collision list return collided; } -@@ -1685,7 +1686,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1684,7 +1685,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } final List stepVoxels = new ArrayList<>(); - final List stepAABBs = entityAABBs; -+ final List stepAABBs = entityCollisionCache.entityAABBs(); // Leaf ++ final List stepAABBs = entityCollisionCache.entityAABBs(); // Leaf // Leaf - cache collision list ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisionsForBlocksOrWorldBorder( this.level, (Entity)(Object)this, stepRetrievalBox, stepVoxels, stepAABBs, -@@ -1699,6 +1700,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1698,6 +1699,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } } -+ entityCollisionCache.clear(); // Leaf ++ entityCollisionCache.clear(); // Leaf - cache collision list return collided; // Paper end - optimise collisions } diff --git a/leaf-server/src/main/java/org/dreeam/leaf/util/BlockMasks.java b/leaf-server/src/main/java/org/dreeam/leaf/util/BlockMasks.java index 509d1eff..5004b67b 100644 --- a/leaf-server/src/main/java/org/dreeam/leaf/util/BlockMasks.java +++ b/leaf-server/src/main/java/org/dreeam/leaf/util/BlockMasks.java @@ -16,7 +16,9 @@ public final class BlockMasks { public static final int TRAP_DOOR_CL = 0x20; public static final int WATER = 0x40; public static final int LAVA = 0x80; - public static final int FLUID = (WATER | LAVA); + + public static final int FLUID = WATER | LAVA; + public static final int IS_STATE_CLIMBABLE = org.dreeam.leaf.util.BlockMasks.CLIMBABLE_TAG | org.dreeam.leaf.util.BlockMasks.POWDER_SNOW_CL; public static int init(final BlockState state) { int i = 0;