2020-07-01 15:53:16 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: JRoy <joshroy126@gmail.com>
|
|
|
|
Date: Mon, 29 Jun 2020 17:03:06 -0400
|
|
|
|
Subject: [PATCH] Remove some streams from structures
|
|
|
|
|
|
|
|
This showed up a lot in the spark profiler, should have a low-medium performance improvement.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BiomeBase.java b/src/main/java/net/minecraft/server/BiomeBase.java
|
2020-08-25 04:22:08 +02:00
|
|
|
index 260fd033c1017389a6f28447a6017b0ca15514d8..0854ac9ef586b378420d9899f3afd2755e6f9f33 100644
|
2020-07-01 15:53:16 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/BiomeBase.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BiomeBase.java
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -209,9 +209,11 @@ public final class BiomeBase {
|
|
|
|
int l1 = j1 << 4;
|
2020-07-01 15:53:16 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
- structuremanager.a(SectionPosition.a(blockposition), structuregenerator).forEach((structurestart) -> {
|
2020-08-25 04:22:08 +02:00
|
|
|
- structurestart.a(regionlimitedworldaccess, structuremanager, chunkgenerator, seededrandom, new StructureBoundingBox(k1, l1, k1 + 15, l1 + 15), new ChunkCoordIntPair(i1, j1));
|
2020-07-01 15:53:16 +02:00
|
|
|
- });
|
|
|
|
+ // Paper start - remove structure streams
|
|
|
|
+ for (StructureStart<?> structureStart : structuremanager.getFeatureStarts(SectionPosition.a(blockposition), structuregenerator)) {
|
2020-08-25 04:22:08 +02:00
|
|
|
+ structureStart.a(regionlimitedworldaccess, structuremanager, chunkgenerator, seededrandom, new StructureBoundingBox(k1, l1, k1 + 15, l1 + 15), new ChunkCoordIntPair(i1, j1));
|
2020-07-01 15:53:16 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
} catch (Exception exception) {
|
|
|
|
CrashReport crashreport = CrashReport.a(exception, "Feature placement");
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java b/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
|
2020-08-25 04:22:08 +02:00
|
|
|
index 4741d28aec73ffa1d5a9f60a4086eac3375c83b1..321ebe8891defb46f3ad3dfea37c9bb6e2025ad7 100644
|
2020-07-01 15:53:16 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -421,7 +421,7 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
|
2020-07-01 15:53:16 +02:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
StructureGenerator<?> structuregenerator = (StructureGenerator) iterator.next();
|
|
|
|
|
|
|
|
- structuremanager.a(SectionPosition.a(chunkcoordintpair, 0), structuregenerator).forEach((structurestart) -> {
|
|
|
|
+ for (StructureStart<?> structurestart : structuremanager.getFeatureStarts(SectionPosition.a(chunkcoordintpair, 0), structuregenerator)) { // Paper - remove structure streams
|
|
|
|
Iterator iterator1 = structurestart.d().iterator();
|
|
|
|
|
|
|
|
while (iterator1.hasNext()) {
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -453,7 +453,7 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
|
2020-07-01 15:53:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- });
|
|
|
|
+ } // Paper - remove structure streams
|
|
|
|
}
|
|
|
|
|
|
|
|
double[][][] adouble = new double[2][this.p + 1][this.o + 1];
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/StructureManager.java b/src/main/java/net/minecraft/server/StructureManager.java
|
2020-08-25 04:22:08 +02:00
|
|
|
index c434427ce7bd206ed5d2efa2560e593b1186c666..f199368a6d78b0cd52f11ca2c8509d729b918852 100644
|
2020-07-01 15:53:16 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/StructureManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/StructureManager.java
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -1,12 +1,13 @@
|
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import com.mojang.datafixers.DataFixUtils;
|
|
|
|
+import it.unimi.dsi.fastutil.objects.ObjectArrayList; // Paper
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
import javax.annotation.Nullable;
|
2020-07-01 15:53:16 +02:00
|
|
|
|
|
|
|
public class StructureManager {
|
|
|
|
|
|
|
|
- private final GeneratorAccess a;
|
|
|
|
+ private final GeneratorAccess a; public GeneratorAccess getLevel() { return a; } // Paper - OBFHELPER
|
|
|
|
private final GeneratorSettings b;
|
|
|
|
|
|
|
|
public StructureManager(GeneratorAccess generatoraccess, GeneratorSettings generatorsettings) {
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -32,6 +33,20 @@ public class StructureManager {
|
2020-07-01 15:53:16 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - remove structure streams
|
|
|
|
+ public java.util.List<StructureStart<?>> getFeatureStarts(SectionPosition sectionPosition, StructureGenerator<?> structureGenerator) {
|
2020-08-25 04:22:08 +02:00
|
|
|
+ java.util.List<StructureStart<?>> list = new ObjectArrayList<>();
|
2020-07-01 15:53:16 +02:00
|
|
|
+ for (Long curLong: getLevel().getChunkAt(sectionPosition.a(), sectionPosition.c(), ChunkStatus.STRUCTURE_REFERENCES).b(structureGenerator)) {
|
|
|
|
+ SectionPosition sectionPosition1 = SectionPosition.a(new ChunkCoordIntPair(curLong), 0);
|
|
|
|
+ StructureStart<?> structurestart = a(sectionPosition1, structureGenerator, getLevel().getChunkAt(sectionPosition1.a(), sectionPosition1.c(), ChunkStatus.STRUCTURE_STARTS));
|
|
|
|
+ if (structurestart != null && structurestart.e()) {
|
|
|
|
+ list.add(structurestart);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
@Nullable
|
|
|
|
public StructureStart<?> a(SectionPosition sectionposition, StructureGenerator<?> structuregenerator, IStructureAccess istructureaccess) {
|
|
|
|
return istructureaccess.a(structuregenerator);
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -50,13 +65,21 @@ public class StructureManager {
|
2020-07-01 15:53:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public StructureStart<?> a(BlockPosition blockposition, boolean flag, StructureGenerator<?> structuregenerator) {
|
|
|
|
- return (StructureStart) DataFixUtils.orElse(this.a(SectionPosition.a(blockposition), structuregenerator).filter((structurestart) -> {
|
|
|
|
- return structurestart.c().b((BaseBlockPosition) blockposition);
|
|
|
|
- }).filter((structurestart) -> {
|
|
|
|
- return !flag || structurestart.d().stream().anyMatch((structurepiece) -> {
|
|
|
|
- return structurepiece.g().b((BaseBlockPosition) blockposition);
|
|
|
|
- });
|
|
|
|
- }).findFirst(), StructureStart.a);
|
|
|
|
+ // Paper start - remove structure streams
|
|
|
|
+ for (StructureStart<?> structurestart : getFeatureStarts(SectionPosition.a(blockposition), structuregenerator)) {
|
|
|
|
+ if (structurestart.c().b(blockposition)) {
|
|
|
|
+ if (!flag) {
|
|
|
|
+ return structurestart;
|
|
|
|
+ }
|
|
|
|
+ for (StructurePiece structurepiece : structurestart.d()) {
|
|
|
|
+ if (structurepiece.g().b(blockposition)) {
|
|
|
|
+ return structurestart;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return StructureStart.a;
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
// Spigot start
|