diff --git a/src/main/java/com/moulberry/axiom/VersionHelper.java b/src/main/java/com/moulberry/axiom/VersionHelper.java index 2729968..c312e90 100644 --- a/src/main/java/com/moulberry/axiom/VersionHelper.java +++ b/src/main/java/com/moulberry/axiom/VersionHelper.java @@ -11,4 +11,12 @@ public class VersionHelper { serverPlayer.connection.send(new ClientboundCustomPayloadPacket(new CustomByteArrayPayload(id, data))); } + public static ResourceLocation createResourceLocation(String composed) { + return ResourceLocation.parse(composed); + } + + public static ResourceLocation createResourceLocation(String namespace, String path) { + return ResourceLocation.fromNamespaceAndPath(namespace, path); + } + } diff --git a/src/main/java/com/moulberry/axiom/View.java b/src/main/java/com/moulberry/axiom/View.java index 5dd2138..5defc45 100644 --- a/src/main/java/com/moulberry/axiom/View.java +++ b/src/main/java/com/moulberry/axiom/View.java @@ -2,8 +2,6 @@ package com.moulberry.axiom; import com.moulberry.axiom.persistence.UUIDDataType; import net.minecraft.core.registries.Registries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -113,7 +111,7 @@ public final class View { view.pinLevel = tag.getOrDefault(PIN_LEVEL_KEY, PersistentDataType.BOOLEAN, false); if (tag.has(LEVEL_KEY)) { String level = tag.get(LEVEL_KEY, PersistentDataType.STRING); - view.level = ResourceKey.create(Registries.DIMENSION, new ResourceLocation(level)); + view.level = ResourceKey.create(Registries.DIMENSION, VersionHelper.createResourceLocation(level)); } view.pinLocation = tag.getOrDefault(PIN_LOCATION_KEY, PersistentDataType.BOOLEAN, false); diff --git a/src/main/java/com/moulberry/axiom/blueprint/BlueprintIo.java b/src/main/java/com/moulberry/axiom/blueprint/BlueprintIo.java index 59bb487..47e8c3a 100644 --- a/src/main/java/com/moulberry/axiom/blueprint/BlueprintIo.java +++ b/src/main/java/com/moulberry/axiom/blueprint/BlueprintIo.java @@ -2,6 +2,7 @@ package com.moulberry.axiom.blueprint; import com.mojang.serialization.Codec; import com.mojang.serialization.Dynamic; +import com.moulberry.axiom.VersionHelper; import com.moulberry.axiom.buffer.CompressedBlockEntity; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; @@ -88,7 +89,7 @@ public class BlueprintIo { long pos = blockPos.asLong(); String id = blockEntityCompound.getString("id"); - BlockEntityType type = BuiltInRegistries.BLOCK_ENTITY_TYPE.get(new ResourceLocation(id)); + BlockEntityType type = BuiltInRegistries.BLOCK_ENTITY_TYPE.get(VersionHelper.createResourceLocation(id)); if (type != null) { PalettedContainer container = blockMap.get(BlockPos.asLong( diff --git a/src/main/java/com/moulberry/axiom/blueprint/ServerBlueprintManager.java b/src/main/java/com/moulberry/axiom/blueprint/ServerBlueprintManager.java index daec893..8cad1c2 100644 --- a/src/main/java/com/moulberry/axiom/blueprint/ServerBlueprintManager.java +++ b/src/main/java/com/moulberry/axiom/blueprint/ServerBlueprintManager.java @@ -26,7 +26,7 @@ public class ServerBlueprintManager { } private static final int MAX_SIZE = 1000000; - private static final ResourceLocation PACKET_BLUEPRINT_MANIFEST_IDENTIFIER = new ResourceLocation("axiom:blueprint_manifest"); + private static final ResourceLocation PACKET_BLUEPRINT_MANIFEST_IDENTIFIER = VersionHelper.createResourceLocation("axiom:blueprint_manifest"); public static void sendManifest(List serverPlayers) { if (registry != null) { diff --git a/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java b/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java index 3f3b004..71075ca 100644 --- a/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java +++ b/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java @@ -16,9 +16,9 @@ import java.util.List; public class AxiomBigPayloadHandler extends ByteToMessageDecoder { - private static final ResourceLocation SET_BUFFER = new ResourceLocation("axiom", "set_buffer"); - private static final ResourceLocation UPLOAD_BLUEPRINT = new ResourceLocation("axiom", "upload_blueprint"); - private static final ResourceLocation REQUEST_CHUNK_DATA = new ResourceLocation("axiom", "request_chunk_data"); + private static final ResourceLocation SET_BUFFER = VersionHelper.createResourceLocation("axiom", "set_buffer"); + private static final ResourceLocation UPLOAD_BLUEPRINT = VersionHelper.createResourceLocation("axiom", "upload_blueprint"); + private static final ResourceLocation REQUEST_CHUNK_DATA = VersionHelper.createResourceLocation("axiom", "request_chunk_data"); private final int payloadId; private final Connection connection; private final SetBlockBufferPacketListener setBlockBuffer; diff --git a/src/main/java/com/moulberry/axiom/packet/BlueprintRequestPacketListener.java b/src/main/java/com/moulberry/axiom/packet/BlueprintRequestPacketListener.java index 151883a..988592c 100644 --- a/src/main/java/com/moulberry/axiom/packet/BlueprintRequestPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/BlueprintRequestPacketListener.java @@ -24,7 +24,7 @@ public class BlueprintRequestPacketListener implements PluginMessageListener { this.plugin = plugin; } - private static final ResourceLocation RESPONSE_PACKET_IDENTIFIER = new ResourceLocation("axiom:response_blueprint"); + private static final ResourceLocation RESPONSE_PACKET_IDENTIFIER = VersionHelper.createResourceLocation("axiom:response_blueprint"); @Override public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) { diff --git a/src/main/java/com/moulberry/axiom/packet/RequestChunkDataPacketListener.java b/src/main/java/com/moulberry/axiom/packet/RequestChunkDataPacketListener.java index ab74492..648c6e9 100644 --- a/src/main/java/com/moulberry/axiom/packet/RequestChunkDataPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/RequestChunkDataPacketListener.java @@ -35,7 +35,7 @@ import java.io.ByteArrayOutputStream; public class RequestChunkDataPacketListener implements PluginMessageListener { - private static final ResourceLocation RESPONSE_ID = new ResourceLocation("axiom:response_chunk_data"); + private static final ResourceLocation RESPONSE_ID = VersionHelper.createResourceLocation("axiom:response_chunk_data"); private final AxiomPaper plugin; public RequestChunkDataPacketListener(AxiomPaper plugin) {