Commits

DerFrZocker authored and md_5 committed 68f888ded33
SPIGOT-7011, SPIGOT-7065: Overhaul of structures
No tags

src/main/java/org/bukkit/craftbukkit/generator/strucutre/CraftStructure.java

Added
1 +package org.bukkit.craftbukkit.generator.strucutre;
2 +
3 +import net.minecraft.core.IRegistry;
4 +import net.minecraft.core.IRegistryCustom;
5 +import org.bukkit.NamespacedKey;
6 +import org.bukkit.Registry;
7 +import org.bukkit.craftbukkit.util.CraftNamespacedKey;
8 +import org.bukkit.generator.structure.Structure;
9 +import org.bukkit.generator.structure.StructureType;
10 +
11 +public class CraftStructure extends Structure {
12 +
13 + public static Structure minecraftToBukkit(net.minecraft.world.level.levelgen.structure.Structure minecraft, IRegistryCustom registryHolder) {
14 + if (minecraft == null) {
15 + return null;
16 + }
17 +
18 + return Registry.STRUCTURE.get(CraftNamespacedKey.fromMinecraft(registryHolder.registryOrThrow(IRegistry.STRUCTURE_REGISTRY).getKey(minecraft)));
19 + }
20 +
21 + public static net.minecraft.world.level.levelgen.structure.Structure bukkitToMinecraft(Structure bukkit) {
22 + if (bukkit == null) {
23 + return null;
24 + }
25 +
26 + return ((CraftStructure) bukkit).getHandle();
27 + }
28 +
29 + private final NamespacedKey key;
30 + private final net.minecraft.world.level.levelgen.structure.Structure structure;
31 + private final StructureType structureType;
32 +
33 + public CraftStructure(NamespacedKey key, net.minecraft.world.level.levelgen.structure.Structure structure) {
34 + this.key = key;
35 + this.structure = structure;
36 + this.structureType = CraftStructureType.minecraftToBukkit(structure.type());
37 + }
38 +
39 + public net.minecraft.world.level.levelgen.structure.Structure getHandle() {
40 + return structure;
41 + }
42 +
43 + @Override
44 + public StructureType getStructureType() {
45 + return structureType;
46 + }
47 +
48 + @Override
49 + public NamespacedKey getKey() {
50 + return key;
51 + }
52 +}

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

Add shortcut