From 76be2651ca873a27a0580ef33ffa30785d8149e0 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:44:59 -0700 Subject: [PATCH] "Downgrade" Vineflower to 1.10.1 release (#10423) * "Downgrade" Vineflower to 1.10.1 release The main thing we lose from the 1.11 snapshots is a recent fix for redundant casts. * Thanks intellij * a --- build.gradle.kts | 4 ++-- .../server/Actually-optimise-explosions.patch | 6 ++--- ...ackByEntityEvent-and-EntityPushedByE.patch | 8 +++---- .../server/Add-PlayerShearBlockEvent.patch | 10 ++++---- ...d-missing-structure-set-seed-configs.patch | 2 +- ...llow-changing-the-EnderDragon-podium.patch | 6 ++--- patches/server/Collision-optimisations.patch | 24 +++++++++---------- .../Configurable-LootPool-luck-formula.patch | 2 +- patches/server/EntityPathfindEvent.patch | 4 ++-- patches/server/Firework-API-s.patch | 2 +- .../Fix-invulnerable-end-crystals.patch | 6 ++--- ...ssing-chunks-due-to-integer-overflow.patch | 2 +- ...and-additions-to-the-SpawnReason-API.patch | 2 +- patches/server/Improve-ServerGUI.patch | 4 +++- .../MC-4-Fix-item-position-desync.patch | 2 +- .../Optimize-Bit-Operations-by-inlining.patch | 12 +++++----- ...ptimize-Collision-to-not-load-chunks.patch | 2 +- patches/server/Optimize-DataBits.patch | 2 +- ...der-Remove-Streams-Optimized-collect.patch | 6 ++--- .../server/Optimize-Voxel-Shape-Merging.patch | 2 +- ...nd-timings-for-sensors-and-behaviors.patch | 6 ++--- patches/server/Rewrite-chunk-system.patch | 2 +- ...prove-performance-of-the-end-generat.patch | 10 ++++---- ...Skip-POI-finding-if-stuck-in-vehicle.patch | 2 +- .../Use-a-Shared-Random-for-Entities.patch | 4 ++-- 25 files changed, 68 insertions(+), 64 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8a445eca12..73ac5cedc6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,7 +69,7 @@ repositories { dependencies { paramMappings("net.fabricmc:yarn:1.20.4+build.1:mergedv2") remapper("net.fabricmc:tiny-remapper:0.10.1:fat") - decompiler("org.vineflower:vineflower:1.11.0-20240412.144930-14") + decompiler("org.vineflower:vineflower:1.10.1") spigotDecompiler("io.papermc:patched-spigot-fernflower:0.1+build.6") paperclip("io.papermc:paperclip:3.0.3") } @@ -80,7 +80,7 @@ paperweight { paramMappingsRepo = paperMavenPublicUrl remapRepo = paperMavenPublicUrl - decompileRepo = "https://s01.oss.sonatype.org/content/repositories/snapshots/" + decompileRepo = paperMavenPublicUrl craftBukkit { fernFlowerJar = layout.file(spigotDecompiler.elements.map { it.single().asFile }) diff --git a/patches/server/Actually-optimise-explosions.patch b/patches/server/Actually-optimise-explosions.patch index cf9d044568..41c2b242a3 100644 --- a/patches/server/Actually-optimise-explosions.patch +++ b/patches/server/Actually-optimise-explosions.patch @@ -513,9 +513,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end - actually optimise explosions float f = explosion.radius() * 2.0F; Vec3 vec3 = explosion.center(); - double d = Math.sqrt(entity.distanceToSqr(vec3)) / f; -- double e = (1.0 - d) * Explosion.getSeenPercent(vec3, entity); + double d = Math.sqrt(entity.distanceToSqr(vec3)) / (double)f; +- double e = (1.0 - d) * (double)Explosion.getSeenPercent(vec3, entity); + double e = (1.0 - d) * seenPercent; // Paper - actually optimise explosions - return (float)((e * e + e) / 2.0 * 7.0 * f + 1.0); + return (float)((e * e + e) / 2.0 * 7.0 * (double)f + 1.0); } } diff --git a/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch b/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch index 641c9970a1..a277eeacae 100644 --- a/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch +++ b/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch @@ -89,10 +89,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/RamTarget.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/RamTarget.java @@ -0,0 +0,0 @@ public class RamTarget extends Behavior { - float f = 0.25F * (i - j); + float f = 0.25F * (float)(i - j); float g = Mth.clamp(entity.getSpeed() * 1.65F, 0.2F, 3.0F) + f; float h = livingEntity.isDamageSourceBlocked(world.damageSources().mobAttack(entity)) ? 0.5F : 1.0F; -- livingEntity.knockback(h * g * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z()); +- livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z()); + livingEntity.knockback(h * g * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z(), entity, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent this.finishRam(world, entity); world.playSound(null, entity, this.getImpactSound.apply(entity), SoundSource.NEUTRAL, 1.0F, 1.0F); @@ -170,9 +170,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/monster/hoglin/HoglinBase.java +++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/HoglinBase.java @@ -0,0 +0,0 @@ public interface HoglinBase { - double j = f * (attacker.level().random.nextFloat() * 0.5F + 0.2F); + double j = f * (double)(attacker.level().random.nextFloat() * 0.5F + 0.2F); Vec3 vec3 = new Vec3(g, 0.0, h).normalize().scale(j).yRot(i); - double k = f * attacker.level().random.nextFloat() * 0.5; + double k = f * (double)attacker.level().random.nextFloat() * 0.5; - target.push(vec3.x, k, vec3.z); + target.push(vec3.x, k, vec3.z, attacker); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent target.hurtMarked = true; diff --git a/patches/server/Add-PlayerShearBlockEvent.patch b/patches/server/Add-PlayerShearBlockEvent.patch index eda34239ee..908c069004 100644 --- a/patches/server/Add-PlayerShearBlockEvent.patch +++ b/patches/server/Add-PlayerShearBlockEvent.patch @@ -60,14 +60,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + for (org.bukkit.inventory.ItemStack item : event.getDrops()) { // Paper - Add PlayerShearBlockEvent ItemEntity itemEntity = new ItemEntity( world, - pos.getX() + 0.5 + direction2.getStepX() * 0.65, - pos.getY() + 0.1, - pos.getZ() + 0.5 + direction2.getStepZ() * 0.65, + (double)pos.getX() + 0.5 + (double)direction2.getStepX() * 0.65, + (double)pos.getY() + 0.1, + (double)pos.getZ() + 0.5 + (double)direction2.getStepZ() * 0.65, - new ItemStack(Items.PUMPKIN_SEEDS, 4) + org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item) // Paper - Add PlayerShearBlockEvent ); itemEntity.setDeltaMovement( - 0.05 * direction2.getStepX() + world.random.nextDouble() * 0.02, 0.05, 0.05 * direction2.getStepZ() + world.random.nextDouble() * 0.02 + 0.05 * (double)direction2.getStepX() + world.random.nextDouble() * 0.02, +@@ -0,0 +0,0 @@ public class PumpkinBlock extends Block { + 0.05 * (double)direction2.getStepZ() + world.random.nextDouble() * 0.02 ); world.addFreshEntity(itemEntity); + } // Paper - Add PlayerShearBlockEvent diff --git a/patches/server/Add-missing-structure-set-seed-configs.patch b/patches/server/Add-missing-structure-set-seed-configs.patch index b8897b769b..5351a00ab9 100644 --- a/patches/server/Add-missing-structure-set-seed-configs.patch +++ b/patches/server/Add-missing-structure-set-seed-configs.patch @@ -197,7 +197,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + worldgenRandom.setLargeFeatureWithSalt(seed, chunkX, chunkZ, saltOverride); + } + // Paper end - Add missing structure set seed configs - return worldgenRandom.nextDouble() < frequency; + return worldgenRandom.nextDouble() < (double)frequency; } - private static boolean legacyArbitrarySaltProbabilityReducer(long seed, int salt, int chunkX, int chunkZ, float frequency) { diff --git a/patches/server/Allow-changing-the-EnderDragon-podium.patch b/patches/server/Allow-changing-the-EnderDragon-podium.patch index ef570b1225..23ac2aa4ec 100644 --- a/patches/server/Allow-changing-the-EnderDragon-podium.patch +++ b/patches/server/Allow-changing-the-EnderDragon-podium.patch @@ -93,9 +93,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 .level() - .getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin())); + .getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - Allow changing the EnderDragon podium - Player player = this.dragon.level().getNearestPlayer(NEAR_EGG_TARGETING, this.dragon, blockPos.getX(), blockPos.getY(), blockPos.getZ()); - int j; - if (player != null) { + Player player = this.dragon + .level() + .getNearestPlayer(NEAR_EGG_TARGETING, this.dragon, (double)blockPos.getX(), (double)blockPos.getY(), (double)blockPos.getZ()); diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java diff --git a/patches/server/Collision-optimisations.patch b/patches/server/Collision-optimisations.patch index 2cc4c0420e..8fd6e24ead 100644 --- a/patches/server/Collision-optimisations.patch +++ b/patches/server/Collision-optimisations.patch @@ -2473,9 +2473,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper end VoxelShape voxelShape = blockState.getCollisionShape(this.collisionGetter, this.pos, this.context); if (voxelShape == Shapes.block()) { -- if (this.box.intersects(i, j, k, i + 1.0, j + 1.0, k + 1.0)) { +- if (this.box.intersects((double)i, (double)j, (double)k, (double)i + 1.0, (double)j + 1.0, (double)k + 1.0)) { + if (io.papermc.paper.util.CollisionUtil.voxelShapeIntersect(this.box, i, j, k, i + 1.0, j + 1.0, k + 1.0)) { // Paper - keep vanilla behavior for voxelshape intersection - See comment in CollisionUtil - return this.resultProvider.apply(this.pos, voxelShape.move(i, j, k)); + return this.resultProvider.apply(this.pos, voxelShape.move((double)i, (double)j, (double)k)); } } else { diff --git a/src/main/java/net/minecraft/world/level/ClipContext.java b/src/main/java/net/minecraft/world/level/ClipContext.java @@ -3237,7 +3237,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end + public AABB(BlockPos pos) { - this(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1); + this((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 1), (double)(pos.getZ() + 1)); } @@ -0,0 +0,0 @@ public class AABB { } @@ -3638,12 +3638,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - l, - m, - n, -- (int)Math.round(minX * l), -- (int)Math.round(minY * m), -- (int)Math.round(minZ * n), -- (int)Math.round(maxX * l), -- (int)Math.round(maxY * m), -- (int)Math.round(maxZ * n) +- (int)Math.round(minX * (double)l), +- (int)Math.round(minY * (double)m), +- (int)Math.round(minZ * (double)n), +- (int)Math.round(maxX * (double)l), +- (int)Math.round(maxY * (double)m), +- (int)Math.round(maxZ * (double)n) + return new ArrayVoxelShape( + BLOCK.shape, + minX == 0.0 && maxX == 1.0 ? io.papermc.paper.util.CollisionUtil.ZERO_ONE : DoubleArrayList.wrap(new double[] { minX, maxX }), @@ -4620,9 +4620,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - Vec3 vec32 = start.add(vec3.scale(0.001)); - return this.shape - .isFullWide( -- this.findIndex(Direction.Axis.X, vec32.x - pos.getX()), -- this.findIndex(Direction.Axis.Y, vec32.y - pos.getY()), -- this.findIndex(Direction.Axis.Z, vec32.z - pos.getZ()) +- this.findIndex(Direction.Axis.X, vec32.x - (double)pos.getX()), +- this.findIndex(Direction.Axis.Y, vec32.y - (double)pos.getY()), +- this.findIndex(Direction.Axis.Z, vec32.z - (double)pos.getZ()) - ) - ? new BlockHitResult(vec32, Direction.getNearest(vec3.x, vec3.y, vec3.z).getOpposite(), pos, true) - : AABB.clip(this.toAabbs(), start, end, pos); diff --git a/patches/server/Configurable-LootPool-luck-formula.patch b/patches/server/Configurable-LootPool-luck-formula.patch index c3fb438778..130dba5e4f 100644 --- a/patches/server/Configurable-LootPool-luck-formula.patch +++ b/patches/server/Configurable-LootPool-luck-formula.patch @@ -43,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 protected abstract class EntryBase implements LootPoolEntry { @Override public int getWeight(float luck) { -- return Math.max(Mth.floor(LootPoolSingletonContainer.this.weight + LootPoolSingletonContainer.this.quality * luck), 0); +- return Math.max(Mth.floor((float)LootPoolSingletonContainer.this.weight + (float)LootPoolSingletonContainer.this.quality * luck), 0); + // Paper start - Configurable LootPool luck formula + // SEE: https://luckformula.emc.gs for details and data + if (LootPoolSingletonContainer.this.lastLuck != null && LootPoolSingletonContainer.this.lastLuck == luck) { diff --git a/patches/server/EntityPathfindEvent.patch b/patches/server/EntityPathfindEvent.patch index cae2534744..c1e891c8e5 100644 --- a/patches/server/EntityPathfindEvent.patch +++ b/patches/server/EntityPathfindEvent.patch @@ -111,7 +111,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end - EntityPathfindEvent if (positions.isEmpty()) { return null; - } else if (this.mob.getY() < this.level.getMinBuildHeight()) { + } else if (this.mob.getY() < (double)this.level.getMinBuildHeight()) { @@ -0,0 +0,0 @@ public abstract class PathNavigation { } else if (this.path != null && !this.path.isDone() && positions.contains(this.targetPos)) { return this.path; @@ -135,7 +135,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end - EntityPathfindEvent this.level.getProfiler().push("pathfind"); BlockPos blockPos = useHeadPos ? this.mob.blockPosition().above() : this.mob.blockPosition(); - int i = (int)(followRange + range); + int i = (int)(followRange + (float)range); diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java diff --git a/patches/server/Firework-API-s.patch b/patches/server/Firework-API-s.patch index aa4cfe46df..ae05150da2 100644 --- a/patches/server/Firework-API-s.patch +++ b/patches/server/Firework-API-s.patch @@ -60,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java +++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java @@ -0,0 +0,0 @@ public class FireworkRocketItem extends Item { - vec3.z + direction.getStepZ() * 0.15, + vec3.z + (double)direction.getStepZ() * 0.15, itemStack ); + fireworkRocketEntity.spawningEntity = context.getPlayer() == null ? null : context.getPlayer().getUUID(); // Paper diff --git a/patches/server/Fix-invulnerable-end-crystals.patch b/patches/server/Fix-invulnerable-end-crystals.patch index 35cd34851d..8a001de277 100644 --- a/patches/server/Fix-invulnerable-end-crystals.patch +++ b/patches/server/Fix-invulnerable-end-crystals.patch @@ -56,9 +56,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java +++ b/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java @@ -0,0 +0,0 @@ public class SpikeFeature extends Feature { - endCrystal.setBeamTarget(config.getCrystalBeamTarget()); - endCrystal.setInvulnerable(config.isCrystalInvulnerable()); - endCrystal.moveTo(spike.getCenterX() + 0.5, spike.getHeight() + 1, spike.getCenterZ() + 0.5, random.nextFloat() * 360.0F, 0.0F); + endCrystal.moveTo( + (double)spike.getCenterX() + 0.5, (double)(spike.getHeight() + 1), (double)spike.getCenterZ() + 0.5, random.nextFloat() * 360.0F, 0.0F + ); + endCrystal.generatedByDragonFight = true; // Paper - Fix invulnerable end crystals world.addFreshEntity(endCrystal); BlockPos blockPos2 = endCrystal.blockPosition(); diff --git a/patches/server/Fix-missing-chunks-due-to-integer-overflow.patch b/patches/server/Fix-missing-chunks-due-to-integer-overflow.patch index e8db523283..934a34e970 100644 --- a/patches/server/Fix-missing-chunks-due-to-integer-overflow.patch +++ b/patches/server/Fix-missing-chunks-due-to-integer-overflow.patch @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 int j = z / 2; int k = x % 2; int l = z % 2; -- float f = 100.0F - Mth.sqrt(x * x + z * z) * 8.0F; +- float f = 100.0F - Mth.sqrt((float)(x * x + z * z)) * 8.0F; + float f = 100.0F - Mth.sqrt((long) x * (long) x + (long) z * (long) z) * 8.0F; // Paper - cast ints to long to avoid integer overflow f = Mth.clamp(f, -100.0F, 80.0F); diff --git a/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch b/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch index f31afc6289..a1e6ff5c18 100644 --- a/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch +++ b/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch @@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java @@ -0,0 +0,0 @@ public class FrogspawnBlock extends Block { int k = random.nextInt(1, 361); - tadpole.moveTo(d, pos.getY() - 0.5, e, k, 0.0F); + tadpole.moveTo(d, (double)pos.getY() - 0.5, e, (float)k, 0.0F); tadpole.setPersistenceRequired(); - world.addFreshEntity(tadpole); + world.addFreshEntity(tadpole, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // Paper - use correct spawn reason diff --git a/patches/server/Improve-ServerGUI.patch b/patches/server/Improve-ServerGUI.patch index ef9212292c..0989340161 100644 --- a/patches/server/Improve-ServerGUI.patch +++ b/patches/server/Improve-ServerGUI.patch @@ -73,7 +73,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + tpsAvg[g] = format( tps[g] ); + } this.msgs[0] = "Memory use: " + l / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)"; - this.msgs[1] = "Avg tick: " + DECIMAL_FORMAT.format((double)this.server.getAverageTickTimeNanos() / TimeUtil.NANOSECONDS_PER_MILLISECOND) + " ms"; + this.msgs[1] = "Avg tick: " + + DECIMAL_FORMAT.format((double)this.server.getAverageTickTimeNanos() / (double)TimeUtil.NANOSECONDS_PER_MILLISECOND) + + " ms"; + this.msgs[2] = "TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg); + // Paper end - Improve ServerGUI this.values[this.vp++ & 0xFF] = (int)(l * 100L / Runtime.getRuntime().maxMemory()); diff --git a/patches/server/MC-4-Fix-item-position-desync.patch b/patches/server/MC-4-Fix-item-position-desync.patch index c984de9969..0f06d8f8a2 100644 --- a/patches/server/MC-4-Fix-item-position-desync.patch +++ b/patches/server/MC-4-Fix-item-position-desync.patch @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @VisibleForTesting static double decode(long value) { -- return value / 4096.0; +- return (double)value / 4096.0; + return value / 4096.0; // Paper - Fix MC-4; diff on change } diff --git a/patches/server/Optimize-Bit-Operations-by-inlining.patch b/patches/server/Optimize-Bit-Operations-by-inlining.patch index f96263e2f8..f1e502a1c2 100644 --- a/patches/server/Optimize-Bit-Operations-by-inlining.patch +++ b/patches/server/Optimize-Bit-Operations-by-inlining.patch @@ -76,9 +76,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static long asLong(int x, int y, int z) { - long l = 0L; -- l |= (x & PACKED_X_MASK) << X_OFFSET; -- l |= (y & PACKED_Y_MASK) << 0; -- return l | (z & PACKED_Z_MASK) << Z_OFFSET; +- l |= ((long)x & PACKED_X_MASK) << X_OFFSET; +- l |= ((long)y & PACKED_Y_MASK) << 0; +- return l | ((long)z & PACKED_Z_MASK) << Z_OFFSET; + return (((long) x & (long) 67108863) << 38) | (((long) y & (long) 4095)) | (((long) z & (long) 67108863) << 12); // Paper - inline constants and simplify } @@ -180,9 +180,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public static long asLong(int x, int y, int z) { - long l = 0L; -- l |= (x & 4194303L) << 42; -- l |= (y & 1048575L) << 0; -- return l | (z & 4194303L) << 20; +- l |= ((long)x & 4194303L) << 42; +- l |= ((long)y & 1048575L) << 0; +- return l | ((long)z & 4194303L) << 20; + return (((long) x & 4194303L) << 42) | (((long) y & 1048575L)) | (((long) z & 4194303L) << 20); // Paper - Simplify to reduce instruction count } diff --git a/patches/server/Optimize-Collision-to-not-load-chunks.patch b/patches/server/Optimize-Collision-to-not-load-chunks.patch index ad5ad34c74..30fdb6dee4 100644 --- a/patches/server/Optimize-Collision-to-not-load-chunks.patch +++ b/patches/server/Optimize-Collision-to-not-load-chunks.patch @@ -88,7 +88,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end VoxelShape voxelShape = blockState.getCollisionShape(this.collisionGetter, this.pos, this.context); if (voxelShape == Shapes.block()) { - if (this.box.intersects(i, j, k, i + 1.0, j + 1.0, k + 1.0)) { + if (this.box.intersects((double)i, (double)j, (double)k, (double)i + 1.0, (double)j + 1.0, (double)k + 1.0)) { diff --git a/src/main/java/net/minecraft/world/level/CollisionGetter.java b/src/main/java/net/minecraft/world/level/CollisionGetter.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/CollisionGetter.java diff --git a/patches/server/Optimize-DataBits.patch b/patches/server/Optimize-DataBits.patch index 5f7f238fbb..28d643119a 100644 --- a/patches/server/Optimize-DataBits.patch +++ b/patches/server/Optimize-DataBits.patch @@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private int cellIndex(int index) { - long l = Integer.toUnsignedLong(this.divideMul); - long m = Integer.toUnsignedLong(this.divideAdd); -- return (int)(index * l + m >> 32 >> this.divideShift); +- return (int)((long)index * l + m >> 32 >> this.divideShift); + //long l = Integer.toUnsignedLong(this.divideMul); // Paper - Perf: Optimize SimpleBitStorage + //long m = Integer.toUnsignedLong(this.divideAdd); // Paper - Perf: Optimize SimpleBitStorage + return (int) (index * this.divideMulUnsigned + this.divideAddUnsigned >> 32 >> this.divideShift); // Paper - Perf: Optimize SimpleBitStorage diff --git a/patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch index 5abb5da66d..91b5b9344b 100644 --- a/patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch +++ b/patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return null; } else { - Map map = positions.stream() -- .collect(Collectors.toMap(pos -> this.nodeEvaluator.getGoal(pos.getX(), pos.getY(), pos.getZ()), Function.identity())); +- .collect(Collectors.toMap(pos -> this.nodeEvaluator.getGoal((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()), Function.identity())); + // Paper start - Perf: remove streams and optimize collection + List> map = Lists.newArrayList(); + for (BlockPos pos : positions) { @@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 int i = 0; - Set set3 = Sets.newHashSetWithExpectedSize(set.size()); + List> entryList = Lists.newArrayListWithExpectedSize(positions.size()); // Paper - optimize collection - int j = (int)(this.maxVisitedNodes * rangeMultiplier); + int j = (int)((float)this.maxVisitedNodes * rangeMultiplier); while (!this.openSet.isEmpty()) { @@ -0,0 +0,0 @@ public class PathFinder { @@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + for (int i1 = 0; i1 < positions.size(); i1++) { + final Map.Entry entry = positions.get(i1); + Target target = entry.getKey(); - if (node.distanceManhattan(target) <= distance) { + if (node.distanceManhattan(target) <= (float)distance) { target.setReached(); - set3.add(target); + entryList.add(entry); diff --git a/patches/server/Optimize-Voxel-Shape-Merging.patch b/patches/server/Optimize-Voxel-Shape-Merging.patch index 14c230a580..16a5277743 100644 --- a/patches/server/Optimize-Voxel-Shape-Merging.patch +++ b/patches/server/Optimize-Voxel-Shape-Merging.patch @@ -93,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper note - Rewrite below as optimized order if instead of nasty ternary if (first instanceof CubePointRange && second instanceof CubePointRange) { long l = lcm(i, j); - if (size * l <= 256L) { + if ((long)size * l <= 256L) { @@ -0,0 +0,0 @@ public final class Shapes { } } diff --git a/patches/server/Rate-options-and-timings-for-sensors-and-behaviors.patch b/patches/server/Rate-options-and-timings-for-sensors-and-behaviors.patch index 82d74d951b..2cbd0da1d5 100644 --- a/patches/server/Rate-options-and-timings-for-sensors-and-behaviors.patch +++ b/patches/server/Rate-options-and-timings-for-sensors-and-behaviors.patch @@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.hasRequiredMemories(entity) && this.checkExtraStartConditions(world, entity)) { this.status = Behavior.Status.RUNNING; int i = this.minDuration + world.getRandom().nextInt(this.maxDuration + 1 - this.minDuration); - this.endTimestamp = time + i; + this.endTimestamp = time + (long)i; + this.timing.startTiming(); // Paper - behavior timings this.start(world, entity, time); + this.timing.stopTiming(); // Paper - behavior timings @@ -116,13 +116,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.timing = co.aikar.timings.MinecraftTimings.getSensorTimings(configKey, senseInterval); + // Paper end this.scanRate = senseInterval; - this.timeToTick = RANDOM.nextInt(senseInterval); + this.timeToTick = (long)RANDOM.nextInt(senseInterval); } @@ -0,0 +0,0 @@ public abstract class Sensor { public final void tick(ServerLevel world, E entity) { if (--this.timeToTick <= 0L) { -- this.timeToTick = this.scanRate; +- this.timeToTick = (long)this.scanRate; + // Paper start - configurable sensor tick rate and timings + this.timeToTick = java.util.Objects.requireNonNullElse(world.paperConfig().tickRates.sensor.get(entity.getType(), this.configKey), this.scanRate); + this.timing.startTiming(); diff --git a/patches/server/Rewrite-chunk-system.patch b/patches/server/Rewrite-chunk-system.patch index 5045db74d8..89241b4225 100644 --- a/patches/server/Rewrite-chunk-system.patch +++ b/patches/server/Rewrite-chunk-system.patch @@ -19217,7 +19217,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void onChunkBatchReceivedByClient(float desiredBatchSize) { + if (true) return; // Paper - rewrite player chunk loader this.unacknowledgedBatches--; - this.desiredChunksPerTick = Double.isNaN(desiredBatchSize) ? 0.01F : Mth.clamp(desiredBatchSize, 0.01F, 64.0F); + this.desiredChunksPerTick = Double.isNaN((double)desiredBatchSize) ? 0.01F : Mth.clamp(desiredBatchSize, 0.01F, 64.0F); if (this.unacknowledgedBatches == 0) { diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/server/Significantly-improve-performance-of-the-end-generat.patch b/patches/server/Significantly-improve-performance-of-the-end-generat.patch index 3d266bd9b3..e7d01a5904 100644 --- a/patches/server/Significantly-improve-performance-of-the-end-generat.patch +++ b/patches/server/Significantly-improve-performance-of-the-end-generat.patch @@ -39,9 +39,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + NoiseCache cache = noiseCache.get().computeIfAbsent(sampler, noiseKey -> new NoiseCache()); // Paper - Perf: Optimize end generation for (int m = -12; m <= 12; m++) { for (int n = -12; n <= 12; n++) { - long o = i + m; - long p = j + n; -- if (o * o + p * p > 4096L && sampler.getValue(o, p) < -0.9F) { + long o = (long)(i + m); + long p = (long)(j + n); +- if (o * o + p * p > 4096L && sampler.getValue((double)o, (double)p) < -0.9F) { - float g = (Mth.abs((float)o) * 3439.0F + Mth.abs((float)p) * 147.0F) % 13.0F + 9.0F; + // Paper start - Perf: Optimize end generation by using a noise cache + long key = net.minecraft.world.level.ChunkPos.asLong((int) o, (int) p); @@ -58,6 +58,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + if (g != Float.MIN_VALUE) { + // Paper end - Perf: Optimize end generation - float h = k - m * 2; - float q = l - n * 2; + float h = (float)(k - m * 2); + float q = (float)(l - n * 2); float r = 100.0F - Mth.sqrt(h * h + q * q) * g; diff --git a/patches/server/Skip-POI-finding-if-stuck-in-vehicle.patch b/patches/server/Skip-POI-finding-if-stuck-in-vehicle.patch index 3d51d5db77..426242c7b7 100644 --- a/patches/server/Skip-POI-finding-if-stuck-in-vehicle.patch +++ b/patches/server/Skip-POI-finding-if-stuck-in-vehicle.patch @@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class AcquirePoi { return false; } else { - mutableLong.setValue(time + 20L + world.getRandom().nextInt(20)); + mutableLong.setValue(time + 20L + (long)world.getRandom().nextInt(20)); + if (entity.getNavigation().isStuck()) mutableLong.add(200); // Paper - Perf: Wait an additional 10s to check again if they're stuck PoiManager poiManager = world.getPoiManager(); long2ObjectMap.long2ObjectEntrySet().removeIf(entry -> !entry.getValue().isStillValid(time)); diff --git a/patches/server/Use-a-Shared-Random-for-Entities.patch b/patches/server/Use-a-Shared-Random-for-Entities.patch index 26cd4a9761..f2362291fe 100644 --- a/patches/server/Use-a-Shared-Random-for-Entities.patch +++ b/patches/server/Use-a-Shared-Random-for-Entities.patch @@ -106,8 +106,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public Squid(EntityType type, Level world) { super(type, world); -- this.random.setSeed(this.getId()); -+ //this.random.setSeed(this.getId()); // Paper - Share random for entities to make them more random +- this.random.setSeed((long)this.getId()); ++ //this.random.setSeed((long)this.getId()); // Paper - Share random for entities to make them more random this.tentacleSpeed = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F; }