9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00

Even better inline world height

This commit is contained in:
Dreeam
2024-11-29 17:55:29 -05:00
parent 2c4d9d40d1
commit 003ee6f427
52 changed files with 50 additions and 25 deletions

View File

@@ -6,7 +6,7 @@ Subject: [PATCH] Do not place player if the server is full
Fix https://github.com/PaperMC/Paper/issues/10668
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 8e3bbc7a0cf2a3e5999738c0f764544f5e64ef4a..a7fadf66ff2935c6a3751f2121b0e1a8860cc3f9 100644
index 6da4b4d3f00527aabf398ab614140bc6f8c7442c..f3b98a4a66cec8d6c9dc46479d573c2fb453837a 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -377,6 +377,13 @@ public abstract class PlayerList {

View File

@@ -8,10 +8,10 @@ avoids multiple casting in Entity#distanceTo, using Math#sqrt directly instead o
these methods more able to be inlined by the JIT compiler.
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 08a3714c530fb375ee729e91965c65efb9e6e3d2..6a19390aff7c8f7170467d2c6306b00779f23082 100644
index c4965b7582edfdf97cac82c1472f8fcc1a880a6b..d55560a12be8846db7c0969f5e72f3d79bf0d9c4 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2368,33 +2368,41 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -2370,33 +2370,41 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.xRotO = this.getXRot();
}

View File

@@ -10,10 +10,10 @@ This issue caused by inconsistent fluid count, because of a condition change
in LevelChunkSection#setBlockState, introduced by Moonrise's block count optimisation
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 6a19390aff7c8f7170467d2c6306b00779f23082..d0bbbd2044809bdb1273248297f5d9fb87011189 100644
index d55560a12be8846db7c0969f5e72f3d79bf0d9c4..3c467580195355fb1a04568e628f601365fdbfe0 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4797,7 +4797,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -4799,7 +4799,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
for (int currY = minYIterate; currY < maxYIterate; ++currY) {
net.minecraft.world.level.chunk.LevelChunkSection section = sections[(currY >> 4) - minSection];

View File

@@ -4,45 +4,70 @@ Date: Fri, 8 Nov 2024 04:07:25 +0100
Subject: [PATCH] Better inline world height
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/WorldUtil.java b/src/main/java/ca/spottedleaf/moonrise/common/util/WorldUtil.java
index af9623240ff2d389aa7090623f507720e7dbab7d..a286c8989f8c53fb896be7a3a8e15f850ece1df8 100644
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/WorldUtil.java
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/WorldUtil.java
@@ -7,6 +7,14 @@ public final class WorldUtil {
// min, max are inclusive
+ public static int getMaxSection(final Level world) {
+ return world.getMaxSection() - 1; // getMaxSection() is exclusive
+ }
+
+ public static int getMinSection(final Level world) {
+ return world.getMinSection();
+ }
+
public static int getMaxSection(final LevelHeightAccessor world) {
return world.getMaxSection() - 1; // getMaxSection() is exclusive
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index a34ae9bfda0df2834565dc3ea1fb48f7f2efc099..704631730cf7679446a98cea6faeb70eb89c9849 100644
index a34ae9bfda0df2834565dc3ea1fb48f7f2efc099..37783156170e3c0315d043963244f6a42e025576 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -733,11 +733,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -732,12 +732,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
// Paper end - optimise random ticking
// Gale start - Airplane - inline level height
private final int minBuildHeight, levelHeightAccessorMinSection, height, maxBuildHeight, levelHeightAccessorMaxSection;
- private final int minBuildHeight, levelHeightAccessorMinSection, height, maxBuildHeight, levelHeightAccessorMaxSection;
- @Override public final int getMaxBuildHeight() { return this.maxBuildHeight; }
- @Override public final int getMinSection() { return this.levelHeightAccessorMinSection; }
- @Override public final int getMaxSection() { return this.levelHeightAccessorMaxSection; }
- @Override public final int getMinBuildHeight() { return this.minBuildHeight; }
- @Override public final int getHeight() { return this.height; }
+ @Override public final int getMaxBuildHeight() { return maxBuildHeight; }
+ @Override public final int getMinSection() { return levelHeightAccessorMinSection; }
+ @Override public final int getMaxSection() { return levelHeightAccessorMaxSection; }
+ @Override public final int getMinBuildHeight() { return minBuildHeight; }
+ private final int height, minBuildHeight, maxBuildHeight, sectionsCount, levelMinSection, levelMaxSection;
+ @Override public final int getHeight() { return height; }
+ @Override public final int getMinBuildHeight() { return minBuildHeight; }
+ @Override public final int getMaxBuildHeight() { return maxBuildHeight; }
+ @Override public final int getSectionsCount() { return sectionsCount; }
+ @Override public final int getMinSection() { return levelMinSection; }
+ @Override public final int getMaxSection() { return levelMaxSection; }
+ @Override public final boolean isOutsideBuildHeight(BlockPos pos) { final int y = pos.getY(); return y < minBuildHeight || y >= maxBuildHeight; }
+ @Override public final boolean isOutsideBuildHeight(int y) { return y < minBuildHeight || y >= maxBuildHeight; }
+ @Override public final int getSectionIndex(int y) { return (y >> 4) - levelMinSection; }
+ @Override public final int getSectionIndexFromSectionY(int coord) { return coord - levelMinSection; }
+ @Override public final int getSectionYFromSectionIndex(int index) { return index + levelMinSection; }
// Gale end - Airplane - inline level height
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.function.Function<org.spigotmc.SpigotWorldConfig, org.galemc.gale.configuration.GaleWorldConfiguration> galeWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray // Gale - Gale configuration // Gale - Purpur - remove vanilla profiler
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
@@ -760,13 +760,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
this.dimensionTypeRegistration = holder;
@@ -761,11 +767,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
final DimensionType dimensionmanager = (DimensionType) holder.value();
- // Gale start - Airplane - inline level height
// Gale start - Airplane - inline level height
- this.minBuildHeight = LevelAccessor.super.getMinBuildHeight();
- this.levelHeightAccessorMinSection = LevelAccessor.super.getMinSection();
- this.height = LevelAccessor.super.getHeight();
- this.maxBuildHeight = LevelAccessor.super.getMaxBuildHeight();
- this.levelHeightAccessorMaxSection = LevelAccessor.super.getMaxSection();
- // Gale end - Airplane - inline level height
+ // Gale start - Airplane - Pluto - inline level height
+ this.minBuildHeight = dimensionmanager.minY();
+ this.levelHeightAccessorMinSection = SectionPos.blockToSectionCoord(dimensionmanager.minY());
+ this.height = dimensionmanager.height();
+ this.maxBuildHeight = dimensionmanager.minY() + dimensionmanager.height();
+ this.levelHeightAccessorMaxSection = SectionPos.blockToSectionCoord((dimensionmanager.minY() + dimensionmanager.height()) - 1) + 1;
+ // Gale end - Airplane - Pluto - inline level height
+ final DimensionType dim = dimensionmanager;
+ this.height = dim.height();
+ this.minBuildHeight = dim.minY();
+ this.maxBuildHeight = dim.minY() + dim.height();
+ this.sectionsCount = (((dim.minY() + dim.height() - 1) >> 4) + 1) - (dim.minY() >> 4);
+ this.levelMinSection = dim.minY() >> 4;
+ this.levelMaxSection = ((dim.minY() + dim.height() - 1) >> 4) + 1;
// Gale end - Airplane - inline level height
this.dimension = resourcekey;
this.isClientSide = flag;
if (dimensionmanager.coordinateScale() != 1.0D) {

View File

@@ -52,7 +52,7 @@ index ca93a97256350789ca56f910862c9d717ca7670b..3a1a5257e1a98cc1d520f407bb1f8c74
private static double getBeardContribution(int x, int y, int z, int yy) {
diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
index c991da3d975e07f3e1e59d5b2e91ed629ea608e6..4a56c06fef4efbed9fa72cf11583f25854c5a9c2 100644
index f7d0eb09640b8b8eeec9269eca867f53e05d023b..a21c77def8c27315b246e3cff4642951a0bf70b6 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
@@ -76,14 +76,13 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {