mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
112 lines
6.1 KiB
Diff
112 lines
6.1 KiB
Diff
|
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
|
||
|
index 30aeb45d63394b7d91c2dd7b92cfc9cefa3c088c..db198811ddecc00cbd398f3805bdf51b3239f390 100644
|
||
|
--- a/src/main/java/net/minecraft/server/BiomeBase.java
|
||
|
+++ b/src/main/java/net/minecraft/server/BiomeBase.java
|
||
|
@@ -339,9 +339,11 @@ public class BiomeBase {
|
||
|
int j1 = l << 4;
|
||
|
|
||
|
try {
|
||
|
- structuremanager.a(SectionPosition.a(blockposition), structuregenerator).forEach((structurestart) -> {
|
||
|
- structurestart.a(generatoraccessseed, structuremanager, chunkgenerator, seededrandom, new StructureBoundingBox(i1, j1, i1 + 15, j1 + 15), new ChunkCoordIntPair(k, l));
|
||
|
- });
|
||
|
+ // Paper start - remove structure streams
|
||
|
+ for (StructureStart<?> structureStart : structuremanager.getFeatureStarts(SectionPosition.a(blockposition), structuregenerator)) {
|
||
|
+ structureStart.a(generatoraccessseed, structuremanager, chunkgenerator, seededrandom, new StructureBoundingBox(i1, j1, i1 + 15, j1 + 15), new ChunkCoordIntPair(k, l));
|
||
|
+ }
|
||
|
+ // 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
|
||
|
index 733c6244e08f6b7277006c1ed801f2cfc8fc36e5..45b771e4121f2ef27c67d5a5ba2dadcfc0f944e0 100644
|
||
|
--- a/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
|
||
|
+++ b/src/main/java/net/minecraft/server/ChunkGeneratorAbstract.java
|
||
|
@@ -417,7 +417,7 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
|
||
|
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()) {
|
||
|
@@ -449,7 +449,7 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- });
|
||
|
+ } // 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
|
||
|
index c434427ce7bd206ed5d2efa2560e593b1186c666..6c7804ac0e994ec03b95eda7a24139b65a59db7e 100644
|
||
|
--- a/src/main/java/net/minecraft/server/StructureManager.java
|
||
|
+++ b/src/main/java/net/minecraft/server/StructureManager.java
|
||
|
@@ -6,7 +6,7 @@ import javax.annotation.Nullable;
|
||
|
|
||
|
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) {
|
||
|
@@ -32,6 +32,20 @@ public class StructureManager {
|
||
|
});
|
||
|
}
|
||
|
|
||
|
+ // Paper start - remove structure streams
|
||
|
+ public java.util.List<StructureStart<?>> getFeatureStarts(SectionPosition sectionPosition, StructureGenerator<?> structureGenerator) {
|
||
|
+ java.util.List<StructureStart<?>> list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>();
|
||
|
+ 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);
|
||
|
@@ -50,13 +64,21 @@ public class StructureManager {
|
||
|
}
|
||
|
|
||
|
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
|