Commits

Martoph authored and md_5 committed f3828bbee61
#989: Add PDC to Structures
No tags

nms-patches/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.patch

Modified
1 1 --- a/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
2 2 +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
3 -@@ -142,7 +142,7 @@
3 +@@ -50,6 +50,12 @@
4 + import net.minecraft.world.phys.shapes.VoxelShapeBitSet;
5 + import net.minecraft.world.phys.shapes.VoxelShapeDiscrete;
6 +
7 ++// CraftBukkit start
8 ++import net.minecraft.nbt.NBTBase;
9 ++import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
10 ++import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
11 ++// CraftBukkit end
12 ++
13 + public class DefinedStructure {
14 +
15 + public static final String PALETTE_TAG = "palette";
16 +@@ -69,6 +75,11 @@
17 + private BaseBlockPosition size;
18 + private String author;
19 +
20 ++ // CraftBukkit start - data containers
21 ++ private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
22 ++ public CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
23 ++ // CraftBukkit end
24 ++
25 + public DefinedStructure() {
26 + this.size = BaseBlockPosition.ZERO;
27 + this.author = "?";
28 +@@ -142,7 +153,7 @@
4 29 }
5 30
6 31 private static List<DefinedStructure.BlockInfo> buildInfoList(List<DefinedStructure.BlockInfo> list, List<DefinedStructure.BlockInfo> list1, List<DefinedStructure.BlockInfo> list2) {
7 32 - Comparator<DefinedStructure.BlockInfo> comparator = Comparator.comparingInt((definedstructure_blockinfo) -> {
8 33 + Comparator<DefinedStructure.BlockInfo> comparator = Comparator.<DefinedStructure.BlockInfo>comparingInt((definedstructure_blockinfo) -> { // CraftBukkit - decompile error
9 34 return definedstructure_blockinfo.pos.getY();
10 35 }).thenComparingInt((definedstructure_blockinfo) -> {
11 36 return definedstructure_blockinfo.pos.getX();
12 -@@ -463,11 +463,13 @@
37 +@@ -463,11 +474,13 @@
13 38 }
14 39
15 40 private static Optional<Entity> createEntityIgnoreException(WorldAccess worldaccess, NBTTagCompound nbttagcompound) {
16 41 - try {
17 42 + // CraftBukkit start
18 43 + // try {
19 44 return EntityTypes.create(nbttagcompound, (World) worldaccess.getLevel());
20 45 - } catch (Exception exception) {
21 46 - return Optional.empty();
22 47 - }
23 48 + // } catch (Exception exception) {
24 49 + // return Optional.empty();
25 50 + // }
26 51 + // CraftBukkit end
27 52 }
28 53
29 54 public BaseBlockPosition getSize(EnumBlockRotation enumblockrotation) {
30 -@@ -860,7 +862,7 @@
55 +@@ -682,6 +695,13 @@
56 + nbttagcompound.put("entities", nbttaglist3);
57 + nbttagcompound.put("size", this.newIntegerList(this.size.getX(), this.size.getY(), this.size.getZ()));
58 + nbttagcompound.putInt("DataVersion", SharedConstants.getCurrentVersion().getWorldVersion());
59 ++
60 ++ // CraftBukkit Start - PDC
61 ++ if (!this.persistentDataContainer.isEmpty()) {
62 ++ nbttagcompound.put("BukkitValues", this.persistentDataContainer.toTagCompound());
63 ++ }
64 ++ // CraftBukkit end
65 ++
66 + return nbttagcompound;
67 + }
68 +
69 +@@ -721,6 +741,12 @@
70 + }
71 + }
72 +
73 ++ // CraftBukkit start - PDC
74 ++ NBTBase base = nbttagcompound.get("BukkitValues");
75 ++ if (base instanceof NBTTagCompound) {
76 ++ this.persistentDataContainer.putAll((NBTTagCompound) base);
77 ++ }
78 ++ // CraftBukkit end
79 + }
80 +
81 + private void loadPalette(NBTTagList nbttaglist, NBTTagList nbttaglist1) {
82 +@@ -860,7 +886,7 @@
31 83 public IBlockData stateFor(int i) {
32 84 IBlockData iblockdata = (IBlockData) this.ids.byId(i);
33 85
34 86 - return iblockdata == null ? DefinedStructure.b.DEFAULT_BLOCK_STATE : iblockdata;
35 87 + return iblockdata == null ? DEFAULT_BLOCK_STATE : iblockdata; // CraftBukkit - decompile error
36 88 }
37 89
38 90 public Iterator<IBlockData> iterator() {

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut