mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-13 21:24:00 +01:00
Fix DensityFunctions lvt
This commit is contained in:
parent
15ad7cc156
commit
8f5d9953f5
3 changed files with 21 additions and 18 deletions
|
@ -4,10 +4,10 @@
|
|||
private static final int GATEWAY_DISTANCE = 96;
|
||||
public static final int DRAGON_SPAWN_Y = 128;
|
||||
private final Predicate<Entity> validPlayer;
|
||||
+ private static final Component DEFAULT_BOSS_EVENT_NAME = Component.translatable("entity.minecraft.ender_dragon"); // Paper - ensure reset EnderDragon boss event name
|
||||
+ private static final Component DEFAULT_BOSS_EVENT_NAME = Component.translatable("entity.minecraft.ender_dragon"); // Paper - reset EnderDragon boss event name
|
||||
public final ServerBossEvent dragonEvent = (ServerBossEvent)new ServerBossEvent(
|
||||
- Component.translatable("entity.minecraft.ender_dragon"), BossEvent.BossBarColor.PINK, BossEvent.BossBarOverlay.PROGRESS
|
||||
+ DEFAULT_BOSS_EVENT_NAME, BossEvent.BossBarColor.PINK, BossEvent.BossBarOverlay.PROGRESS // Paper
|
||||
+ DEFAULT_BOSS_EVENT_NAME, BossEvent.BossBarColor.PINK, BossEvent.BossBarOverlay.PROGRESS // Paper - reset EnderDragon boss event name
|
||||
)
|
||||
.setPlayBossMusic(true)
|
||||
.setCreateWorldFog(true);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
+ LOGGER.error("Overwrote an existing entity {} with {}", oldCast, entity);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ // Paper end - extra debug info
|
||||
} else {
|
||||
this.byUuid.put(uuid, entity);
|
||||
this.byId.put(entity.getId(), entity);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
public EndIslandDensityFunction(long seed) {
|
||||
RandomSource randomSource = new LegacyRandomSource(seed);
|
||||
@@ -518,15 +_,29 @@
|
||||
@@ -518,15 +_,31 @@
|
||||
int i1 = z / 2;
|
||||
int i2 = x % 2;
|
||||
int i3 = z % 2;
|
||||
|
@ -28,22 +28,25 @@
|
|||
+ NoiseCache cache = noiseCache.get().computeIfAbsent(noise, noiseKey -> new NoiseCache()); // Paper - Perf: Optimize end generation
|
||||
for (int i4 = -12; i4 <= 12; i4++) {
|
||||
for (int i5 = -12; i5 <= 12; i5++) {
|
||||
long l = i + i4;
|
||||
long l1 = i1 + i5;
|
||||
- if (l * l + l1 * l1 > 4096L && noise.getValue(l, l1) < -0.9F) {
|
||||
- float f1 = (Mth.abs((float)l) * 3439.0F + Mth.abs((float)l1) * 147.0F) % 13.0F + 9.0F;
|
||||
- long l = i + i4;
|
||||
- long l1 = i1 + i5;
|
||||
+ long l = i + i4; final int chunkX = (int) l; // Paper - OBFHELPER
|
||||
+ long l1 = i1 + i5; final int chunkZ = (int) l1; // Paper - OBFHELPER
|
||||
+ // Paper start - Perf: Optimize end generation by using a noise cache
|
||||
+ long key = net.minecraft.world.level.ChunkPos.asLong((int) l, (int) l);
|
||||
+ int index = (int) it.unimi.dsi.fastutil.HashCommon.mix(key) & 8191;
|
||||
+ float f1 = Float.MIN_VALUE;
|
||||
+ if (cache.keys[index] == key) {
|
||||
+ f1 = cache.values[index];
|
||||
+ final long chunkKey = net.minecraft.world.level.ChunkPos.asLong(chunkX, chunkZ);
|
||||
+ final int cacheIndex = (int) it.unimi.dsi.fastutil.HashCommon.mix(chunkKey) & 8191;
|
||||
+ float f1 = Float.MIN_VALUE; // noise value
|
||||
+ if (cache.keys[cacheIndex] == chunkKey) {
|
||||
+ // Use cache
|
||||
+ f1 = cache.values[cacheIndex];
|
||||
+ } else {
|
||||
+ if (l * l + l1 * l1 > 4096L && noise.getValue((double)l, (double)l1) < -0.9F) {
|
||||
+ f1 = (Mth.abs((float)l) * 3439.0F + Mth.abs((float)l1) * 147.0F) % 13.0F + 9.0F;
|
||||
+ }
|
||||
+ cache.keys[index] = key;
|
||||
+ cache.values[index] = f1;
|
||||
+ // Vanilla function
|
||||
if (l * l + l1 * l1 > 4096L && noise.getValue(l, l1) < -0.9F) {
|
||||
- float f1 = (Mth.abs((float)l) * 3439.0F + Mth.abs((float)l1) * 147.0F) % 13.0F + 9.0F;
|
||||
+ f1 = (Mth.abs((float)l) * 3439.0F + Mth.abs((float)l1) * 147.0F) % 13.0F + 9.0F;
|
||||
+ }
|
||||
+ cache.keys[cacheIndex] = chunkKey;
|
||||
+ cache.values[cacheIndex] = f1;
|
||||
+ }
|
||||
+ if (f1 != Float.MIN_VALUE) {
|
||||
+ // Paper end - Perf: Optimize end generation
|
||||
|
|
Loading…
Reference in a new issue