forked from BLOCKFANTASY/LOOHP-Limbo
Use Adventure Key replacing NamespacedKey
This commit is contained in:
@@ -19,16 +19,15 @@
|
||||
|
||||
package com.loohp.limbo.world;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.loohp.limbo.utils.NamespacedKey;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import net.querz.nbt.tag.StringTag;
|
||||
import net.querz.nbt.tag.Tag;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class BlockState {
|
||||
|
||||
private CompoundTag tag;
|
||||
@@ -41,12 +40,12 @@ public class BlockState {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public NamespacedKey getType() {
|
||||
return new NamespacedKey(tag.getString("Name"));
|
||||
public Key getType() {
|
||||
return Key.key(tag.getString("Name"));
|
||||
}
|
||||
|
||||
public void setType(NamespacedKey namespacedKey) {
|
||||
tag.putString("Name", namespacedKey.toString());
|
||||
public void setType(Key Key) {
|
||||
tag.putString("Name", Key.toString());
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package com.loohp.limbo.world;
|
||||
|
||||
import com.loohp.limbo.location.Location;
|
||||
|
||||
import net.querz.mca.Chunk;
|
||||
|
||||
public class ChunkPosition {
|
||||
|
||||
@@ -19,23 +19,20 @@
|
||||
|
||||
package com.loohp.limbo.world;
|
||||
|
||||
import com.loohp.limbo.Limbo;
|
||||
import com.loohp.limbo.utils.CustomNBTUtils;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import com.loohp.limbo.Limbo;
|
||||
import com.loohp.limbo.utils.CustomNBTUtils;
|
||||
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
|
||||
public class DimensionRegistry {
|
||||
|
||||
private CompoundTag defaultTag;
|
||||
|
||||
@@ -19,57 +19,57 @@
|
||||
|
||||
package com.loohp.limbo.world;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.loohp.limbo.utils.NamespacedKey;
|
||||
|
||||
public class Environment {
|
||||
|
||||
public static final Environment NORMAL = new Environment(new NamespacedKey("minecraft:overworld"), true);
|
||||
public static final Environment NETHER = new Environment(new NamespacedKey("minecraft:the_nether"), false);
|
||||
public static final Environment END = new Environment(new NamespacedKey("minecraft:the_end"), false);
|
||||
public static final Environment NORMAL = new Environment(Key.key("minecraft:overworld"), true);
|
||||
public static final Environment NETHER = new Environment(Key.key("minecraft:the_nether"), false);
|
||||
public static final Environment END = new Environment(Key.key("minecraft:the_end"), false);
|
||||
|
||||
public static final Set<Environment> REGISTERED_ENVIRONMENTS = new HashSet<>();
|
||||
|
||||
public static Environment fromNamespacedKey(NamespacedKey key) {
|
||||
if (key.equals(NORMAL.getNamespacedKey())) {
|
||||
public static Environment fromKey(Key key) {
|
||||
if (key.equals(NORMAL.getKey())) {
|
||||
return NORMAL;
|
||||
} else if (key.equals(NETHER.getNamespacedKey())) {
|
||||
} else if (key.equals(NETHER.getKey())) {
|
||||
return NETHER;
|
||||
} else if (key.equals(END.getNamespacedKey())) {
|
||||
} else if (key.equals(END.getKey())) {
|
||||
return END;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Environment createCustom(NamespacedKey key) {
|
||||
public static Environment createCustom(Key key) {
|
||||
return createCustom(key, true);
|
||||
}
|
||||
|
||||
public static Environment createCustom(NamespacedKey key, boolean hasSkyLight) {
|
||||
if (REGISTERED_ENVIRONMENTS.stream().anyMatch(each -> each.getNamespacedKey().equals(key))) {
|
||||
throw new IllegalArgumentException("An Environment is already created with this NamespacedKey");
|
||||
public static Environment createCustom(Key key, boolean hasSkyLight) {
|
||||
if (REGISTERED_ENVIRONMENTS.stream().anyMatch(each -> each.getKey().equals(key))) {
|
||||
throw new IllegalArgumentException("An Environment is already created with this Key");
|
||||
}
|
||||
return new Environment(key, hasSkyLight);
|
||||
}
|
||||
|
||||
public static Environment getCustom(NamespacedKey key) {
|
||||
return REGISTERED_ENVIRONMENTS.stream().filter(each -> each.getNamespacedKey().equals(key)).findFirst().orElse(null);
|
||||
public static Environment getCustom(Key key) {
|
||||
return REGISTERED_ENVIRONMENTS.stream().filter(each -> each.getKey().equals(key)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
//=========================
|
||||
|
||||
private NamespacedKey key;
|
||||
private Key key;
|
||||
private boolean hasSkyLight;
|
||||
|
||||
private Environment(NamespacedKey key, boolean hasSkyLight) {
|
||||
private Environment(Key key, boolean hasSkyLight) {
|
||||
this.key = key;
|
||||
this.hasSkyLight = hasSkyLight;
|
||||
}
|
||||
|
||||
public NamespacedKey getNamespacedKey() {
|
||||
public Key getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,13 @@
|
||||
|
||||
package com.loohp.limbo.world;
|
||||
|
||||
import com.loohp.limbo.Limbo;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
@@ -28,15 +35,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import com.loohp.limbo.Limbo;
|
||||
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
|
||||
public class GeneratedBlockDataMappings {
|
||||
|
||||
private static JSONObject globalPalette = new JSONObject();
|
||||
|
||||
@@ -19,16 +19,15 @@
|
||||
|
||||
package com.loohp.limbo.world;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import com.loohp.limbo.utils.SchematicConvertionUtils;
|
||||
|
||||
import com.loohp.limbo.utils.SchematicConversionUtils;
|
||||
import net.querz.mca.Chunk;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import net.querz.nbt.tag.ListTag;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class Schematic {
|
||||
|
||||
@@ -81,7 +80,7 @@ public class Schematic {
|
||||
|
||||
if (pos[0] == x && pos[1] == y && pos[2] == z) {
|
||||
ListTag<CompoundTag> newTag = chunk.getTileEntities();
|
||||
newTag.add(SchematicConvertionUtils.toTileEntityTag(tag));
|
||||
newTag.add(SchematicConversionUtils.toTileEntityTag(tag));
|
||||
chunk.setTileEntities(newTag);
|
||||
itr.remove();
|
||||
break;
|
||||
|
||||
@@ -19,16 +19,6 @@
|
||||
|
||||
package com.loohp.limbo.world;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.loohp.limbo.Limbo;
|
||||
import com.loohp.limbo.entity.ArmorStand;
|
||||
import com.loohp.limbo.entity.DataWatcher;
|
||||
@@ -39,12 +29,21 @@ import com.loohp.limbo.location.Location;
|
||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityDestroy;
|
||||
import com.loohp.limbo.network.protocol.packets.PacketPlayOutEntityMetadata;
|
||||
import com.loohp.limbo.player.Player;
|
||||
import com.loohp.limbo.utils.SchematicConvertionUtils;
|
||||
|
||||
import com.loohp.limbo.utils.SchematicConversionUtils;
|
||||
import net.querz.mca.Chunk;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import net.querz.nbt.tag.ListTag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class World {
|
||||
|
||||
public static final CompoundTag HEIGHT_MAP = new CompoundTag();
|
||||
@@ -122,7 +121,7 @@ public class World {
|
||||
chunk = Chunk.newChunk();
|
||||
this.chunks[(x >> 4)][(z >> 4)] = chunk;
|
||||
}
|
||||
CompoundTag block = SchematicConvertionUtils.toBlockTag(blockdata);
|
||||
CompoundTag block = SchematicConversionUtils.toBlockTag(blockdata);
|
||||
chunk.setBlockStateAt(x, y, z, block, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user