#1335: Add API for in-world structures
By: coll1234567 <joshl5324@gmail.com>
This commit is contained in:
@@ -114,3 +114,16 @@
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@@ -545,6 +563,12 @@
|
||||
StructureStart structurestart = StructureStart.loadStaticStart(structurepieceserializationcontext, nbttagcompound1.getCompound(s), i);
|
||||
|
||||
if (structurestart != null) {
|
||||
+ // CraftBukkit start - load persistent data for structure start
|
||||
+ net.minecraft.nbt.NBTBase persistentBase = nbttagcompound1.getCompound(s).get("StructureBukkitValues");
|
||||
+ if (persistentBase instanceof NBTTagCompound) {
|
||||
+ structurestart.persistentDataContainer.putAll((NBTTagCompound) persistentBase);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
map.put(structure, structurestart);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
--- a/net/minecraft/world/level/levelgen/structure/StructureStart.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/StructureStart.java
|
||||
@@ -31,6 +31,7 @@
|
||||
private int references;
|
||||
@@ -32,6 +32,12 @@
|
||||
@Nullable
|
||||
private volatile StructureBoundingBox cachedBoundingBox;
|
||||
+ public org.bukkit.event.world.AsyncStructureGenerateEvent.Cause generationEventCause = org.bukkit.event.world.AsyncStructureGenerateEvent.Cause.WORLD_GENERATION; // CraftBukkit
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry();
|
||||
+ public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(DATA_TYPE_REGISTRY);
|
||||
+ public org.bukkit.event.world.AsyncStructureGenerateEvent.Cause generationEventCause = org.bukkit.event.world.AsyncStructureGenerateEvent.Cause.WORLD_GENERATION;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public StructureStart(Structure structure, ChunkCoordIntPair chunkcoordintpair, int i, PiecesContainer piecescontainer) {
|
||||
this.structure = structure;
|
||||
@@ -91,6 +92,8 @@
|
||||
this.chunkPos = chunkcoordintpair;
|
||||
@@ -91,6 +97,8 @@
|
||||
StructureBoundingBox structureboundingbox1 = ((StructurePiece) list.get(0)).boundingBox;
|
||||
BlockPosition blockposition = structureboundingbox1.getCenter();
|
||||
BlockPosition blockposition1 = new BlockPosition(blockposition.getX(), structureboundingbox1.minY(), blockposition.getZ());
|
||||
@@ -17,7 +22,7 @@
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -100,6 +103,18 @@
|
||||
@@ -100,6 +108,18 @@
|
||||
structurepiece.postProcess(generatoraccessseed, structuremanager, chunkgenerator, randomsource, structureboundingbox, chunkcoordintpair, blockposition1);
|
||||
}
|
||||
}
|
||||
@@ -36,3 +41,15 @@
|
||||
|
||||
this.structure.afterPlace(generatoraccessseed, structuremanager, chunkgenerator, randomsource, structureboundingbox, chunkcoordintpair, this.pieceContainer);
|
||||
}
|
||||
@@ -107,6 +127,11 @@
|
||||
|
||||
public NBTTagCompound createTag(StructurePieceSerializationContext structurepieceserializationcontext, ChunkCoordIntPair chunkcoordintpair) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
+ // CraftBukkit start - store persistent data in nbt
|
||||
+ if (!persistentDataContainer.isEmpty()) {
|
||||
+ nbttagcompound.put("StructureBukkitValues", persistentDataContainer.toTagCompound());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (this.isValid()) {
|
||||
nbttagcompound.putString("id", structurepieceserializationcontext.registryAccess().registryOrThrow(Registries.STRUCTURE).getKey(this.structure).toString());
|
||||
|
||||
Reference in New Issue
Block a user