2020-07-01 13:53:16 +00: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.
|
|
|
|
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/StructureManager.java b/src/main/java/net/minecraft/world/level/StructureManager.java
|
|
|
|
index a6a3bd3d60c30859b5a59e057d430c826d93e83c..a21b19a8fc2ecf01a49f20b611280d878c1d9100 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/level/StructureManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/StructureManager.java
|
|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
package net.minecraft.world.level;
|
2020-08-25 02:22:08 +00:00
|
|
|
|
|
|
|
import com.mojang.datafixers.DataFixUtils;
|
|
|
|
+import it.unimi.dsi.fastutil.objects.ObjectArrayList; // Paper
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
import javax.annotation.Nullable;
|
2021-03-16 07:19:45 +00:00
|
|
|
import net.minecraft.core.BaseBlockPosition;
|
|
|
|
@@ -15,7 +16,7 @@ import net.minecraft.world.level.levelgen.structure.StructureStart;
|
2020-07-01 13:53:16 +00: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) {
|
2021-03-16 07:19:45 +00:00
|
|
|
@@ -41,6 +42,20 @@ public class StructureManager {
|
2020-07-01 13:53:16 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - remove structure streams
|
|
|
|
+ public java.util.List<StructureStart<?>> getFeatureStarts(SectionPosition sectionPosition, StructureGenerator<?> structureGenerator) {
|
2020-08-25 02:22:08 +00:00
|
|
|
+ java.util.List<StructureStart<?>> list = new ObjectArrayList<>();
|
2020-07-01 13:53:16 +00: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);
|
2021-03-16 07:19:45 +00:00
|
|
|
@@ -59,13 +74,21 @@ public class StructureManager {
|
2020-07-01 13:53:16 +00: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
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/biome/BiomeBase.java b/src/main/java/net/minecraft/world/level/biome/BiomeBase.java
|
|
|
|
index 7147cdda756ccb3d4f6880802128f68601783883..3a050fc7d7abeb3c85b6a5d4d3751cdd9a77c82f 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/level/biome/BiomeBase.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/biome/BiomeBase.java
|
|
|
|
@@ -238,9 +238,11 @@ public final class BiomeBase {
|
|
|
|
int l1 = j1 << 4;
|
|
|
|
|
|
|
|
try {
|
|
|
|
- structuremanager.a(SectionPosition.a(blockposition), structuregenerator).forEach((structurestart) -> {
|
|
|
|
- structurestart.a(regionlimitedworldaccess, structuremanager, chunkgenerator, seededrandom, new StructureBoundingBox(k1, l1, k1 + 15, l1 + 15), new ChunkCoordIntPair(i1, j1));
|
|
|
|
- });
|
|
|
|
+ // Paper start - remove structure streams
|
|
|
|
+ for (StructureStart<?> structureStart : structuremanager.getFeatureStarts(SectionPosition.a(blockposition), structuregenerator)) {
|
|
|
|
+ structureStart.a(regionlimitedworldaccess, structuremanager, chunkgenerator, seededrandom, new StructureBoundingBox(k1, l1, k1 + 15, l1 + 15), new ChunkCoordIntPair(i1, j1));
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
} catch (Exception exception) {
|
|
|
|
CrashReport crashreport = CrashReport.a(exception, "Feature placement");
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.java b/src/main/java/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.java
|
|
|
|
index 700b32322e8d0fbb8ec2824e50a340be16b48f81..d842cb5a8fdcdd8f77c7b44cc83c8341f947d7b3 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/ChunkGeneratorAbstract.java
|
|
|
|
@@ -455,7 +455,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()) {
|
|
|
|
@@ -487,7 +487,7 @@ public final class ChunkGeneratorAbstract extends ChunkGenerator {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- });
|
|
|
|
+ } // Paper - remove structure streams
|
|
|
|
}
|
|
|
|
|
|
|
|
double[][][] adouble = new double[2][this.p + 1][this.o + 1];
|