mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 19:55:52 -07:00
SPIGOT-2903: Add Structure API
By: Sander Knauff <sanderknauff@hotmail.com>
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
--- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
|
||||
@@ -64,8 +64,8 @@
|
||||
public static final String ENTITY_TAG_NBT = "nbt";
|
||||
public static final String SIZE_TAG = "size";
|
||||
static final int CHUNK_SIZE = 16;
|
||||
- private final List<DefinedStructure.a> palettes = Lists.newArrayList();
|
||||
- private final List<DefinedStructure.EntityInfo> entityInfoList = Lists.newArrayList();
|
||||
+ public final List<DefinedStructure.a> palettes = Lists.newArrayList(); // PAIL private->public
|
||||
+ public final List<DefinedStructure.EntityInfo> entityInfoList = Lists.newArrayList(); // PAIL private->public
|
||||
private BaseBlockPosition size;
|
||||
private String author;
|
||||
|
||||
@@ -147,7 +147,7 @@
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,25 @@
|
||||
--- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureInfo.java
|
||||
@@ -24,7 +24,7 @@
|
||||
@Nullable
|
||||
private Random random;
|
||||
@Nullable
|
||||
- private int palette;
|
||||
+ public int palette = -1; // CraftBukkit - Set initial value so we know if the palette has been set forcefully
|
||||
private final List<DefinedStructureProcessor> processors;
|
||||
private boolean knownShape;
|
||||
private boolean finalizeEntities;
|
||||
@@ -151,6 +151,13 @@
|
||||
|
||||
if (i == 0) {
|
||||
throw new IllegalStateException("No palettes");
|
||||
+ // CraftBukkit start
|
||||
+ } else if (this.palette > 0) {
|
||||
+ if (this.palette >= i) {
|
||||
+ throw new IllegalArgumentException("Palette index out of bounds. Got " + this.palette + " where there are only " + i + " palettes available.");
|
||||
+ }
|
||||
+ return list.get(this.palette);
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
return (DefinedStructure.a) list.get(this.b(blockposition).nextInt(i));
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
--- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructureManager.java
|
||||
@@ -34,7 +34,7 @@
|
||||
private static final String STRUCTURE_DIRECTORY_NAME = "structures";
|
||||
private static final String STRUCTURE_FILE_EXTENSION = ".nbt";
|
||||
private static final String STRUCTURE_TEXT_FILE_EXTENSION = ".snbt";
|
||||
- private final Map<MinecraftKey, Optional<DefinedStructure>> structureRepository = Maps.newConcurrentMap();
|
||||
+ public final Map<MinecraftKey, Optional<DefinedStructure>> structureRepository = Maps.newConcurrentMap(); // PAIL private->public
|
||||
private final DataFixer fixerUpper;
|
||||
private IResourceManager resourceManager;
|
||||
private final Path generatedDir;
|
||||
@@ -71,7 +71,7 @@
|
||||
this.structureRepository.clear();
|
||||
}
|
||||
|
||||
- private Optional<DefinedStructure> e(MinecraftKey minecraftkey) {
|
||||
+ public Optional<DefinedStructure> e(MinecraftKey minecraftkey) { // PAIL private->public
|
||||
MinecraftKey minecraftkey1 = new MinecraftKey(minecraftkey.getNamespace(), "structures/" + minecraftkey.getKey() + ".nbt");
|
||||
|
||||
try {
|
||||
@@ -106,7 +106,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- private Optional<DefinedStructure> f(MinecraftKey minecraftkey) {
|
||||
+ public Optional<DefinedStructure> f(MinecraftKey minecraftkey) { // PAIL private->public
|
||||
if (!this.generatedDir.toFile().isDirectory()) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
@@ -140,7 +140,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- private DefinedStructure a(InputStream inputstream) throws IOException {
|
||||
+ public DefinedStructure a(InputStream inputstream) throws IOException { //PAIL rename loadFromStream; private -> public
|
||||
NBTTagCompound nbttagcompound = NBTCompressedStreamTools.a(inputstream);
|
||||
|
||||
return this.a(nbttagcompound);
|
||||
@@ -214,7 +214,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- private Path b(MinecraftKey minecraftkey, String s) {
|
||||
+ public Path b(MinecraftKey minecraftkey, String s) { //PAIL private->public
|
||||
if (minecraftkey.getKey().contains("//")) {
|
||||
throw new ResourceKeyInvalidException("Invalid resource path: " + minecraftkey);
|
||||
} else {
|
Reference in New Issue
Block a user