3
0
Mirror von https://github.com/Moulberry/AxiomPaperPlugin.git synchronisiert 2024-11-17 05:40:06 +01:00

Use VersionHelper to create resource location

Dieser Commit ist enthalten in:
Moulberry 2024-06-27 01:35:46 +08:00
Ursprung 758e0b44d1
Commit 18b561c8d1
7 geänderte Dateien mit 17 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -12,4 +12,12 @@ public class VersionHelper {
serverPlayer.connection.send(new ClientboundCustomPayloadPacket(id, new FriendlyByteBuf(Unpooled.wrappedBuffer(data)))); serverPlayer.connection.send(new ClientboundCustomPayloadPacket(id, new FriendlyByteBuf(Unpooled.wrappedBuffer(data))));
} }
public static ResourceLocation createResourceLocation(String composed) {
return ResourceLocation.parse(composed);
}
public static ResourceLocation createResourceLocation(String namespace, String path) {
return ResourceLocation.fromNamespaceAndPath(namespace, path);
}
} }

Datei anzeigen

@ -2,8 +2,6 @@ package com.moulberry.axiom;
import com.moulberry.axiom.persistence.UUIDDataType; import com.moulberry.axiom.persistence.UUIDDataType;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -113,7 +111,7 @@ public final class View {
view.pinLevel = tag.getOrDefault(PIN_LEVEL_KEY, PersistentDataType.BOOLEAN, false); view.pinLevel = tag.getOrDefault(PIN_LEVEL_KEY, PersistentDataType.BOOLEAN, false);
if (tag.has(LEVEL_KEY)) { if (tag.has(LEVEL_KEY)) {
String level = tag.get(LEVEL_KEY, PersistentDataType.STRING); 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); view.pinLocation = tag.getOrDefault(PIN_LOCATION_KEY, PersistentDataType.BOOLEAN, false);

Datei anzeigen

@ -2,6 +2,7 @@ package com.moulberry.axiom.blueprint;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
import com.mojang.serialization.Dynamic; import com.mojang.serialization.Dynamic;
import com.moulberry.axiom.VersionHelper;
import com.moulberry.axiom.buffer.CompressedBlockEntity; import com.moulberry.axiom.buffer.CompressedBlockEntity;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
@ -88,7 +89,7 @@ public class BlueprintIo {
long pos = blockPos.asLong(); long pos = blockPos.asLong();
String id = blockEntityCompound.getString("id"); 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) { if (type != null) {
PalettedContainer<BlockState> container = blockMap.get(BlockPos.asLong( PalettedContainer<BlockState> container = blockMap.get(BlockPos.asLong(

Datei anzeigen

@ -26,7 +26,7 @@ public class ServerBlueprintManager {
} }
private static final int MAX_SIZE = 1000000; 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<ServerPlayer> serverPlayers) { public static void sendManifest(List<ServerPlayer> serverPlayers) {
if (registry != null) { if (registry != null) {

Datei anzeigen

@ -16,9 +16,9 @@ import java.util.List;
public class AxiomBigPayloadHandler extends ByteToMessageDecoder { public class AxiomBigPayloadHandler extends ByteToMessageDecoder {
private static final ResourceLocation SET_BUFFER = new ResourceLocation("axiom", "set_buffer"); private static final ResourceLocation SET_BUFFER = VersionHelper.createResourceLocation("axiom", "set_buffer");
private static final ResourceLocation UPLOAD_BLUEPRINT = new ResourceLocation("axiom", "upload_blueprint"); private static final ResourceLocation UPLOAD_BLUEPRINT = VersionHelper.createResourceLocation("axiom", "upload_blueprint");
private static final ResourceLocation REQUEST_CHUNK_DATA = new ResourceLocation("axiom", "request_chunk_data"); private static final ResourceLocation REQUEST_CHUNK_DATA = VersionHelper.createResourceLocation("axiom", "request_chunk_data");
private final int payloadId; private final int payloadId;
private final Connection connection; private final Connection connection;
private final SetBlockBufferPacketListener setBlockBuffer; private final SetBlockBufferPacketListener setBlockBuffer;

Datei anzeigen

@ -24,7 +24,7 @@ public class BlueprintRequestPacketListener implements PluginMessageListener {
this.plugin = plugin; 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 @Override
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) { public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {

Datei anzeigen

@ -34,7 +34,7 @@ import java.io.ByteArrayOutputStream;
public class RequestChunkDataPacketListener implements PluginMessageListener { 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; private final AxiomPaper plugin;
public RequestChunkDataPacketListener(AxiomPaper plugin) { public RequestChunkDataPacketListener(AxiomPaper plugin) {