mirror of
https://github.com/Nan1t/NanoLimbo.git
synced 2025-07-13 21:20:12 +02:00
Support 1.18.2
This commit is contained in:
parent
9269751ed1
commit
7fb11d2ffb
@ -154,6 +154,9 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
|
|||||||
if (PacketSnapshots.PACKET_HEADER_AND_FOOTER != null)
|
if (PacketSnapshots.PACKET_HEADER_AND_FOOTER != null)
|
||||||
writePacket(PacketSnapshots.PACKET_HEADER_AND_FOOTER);
|
writePacket(PacketSnapshots.PACKET_HEADER_AND_FOOTER);
|
||||||
|
|
||||||
|
if (clientVersion.moreOrEqual(Version.V1_18_2))
|
||||||
|
writePacket(PacketSnapshots.PACKET_EMPTY_CHUNK);
|
||||||
|
|
||||||
sendKeepAlive();
|
sendKeepAlive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ public final class PacketSnapshots {
|
|||||||
public static PacketSnapshot PACKET_JOIN_MESSAGE;
|
public static PacketSnapshot PACKET_JOIN_MESSAGE;
|
||||||
public static PacketSnapshot PACKET_BOSS_BAR;
|
public static PacketSnapshot PACKET_BOSS_BAR;
|
||||||
public static PacketSnapshot PACKET_HEADER_AND_FOOTER;
|
public static PacketSnapshot PACKET_HEADER_AND_FOOTER;
|
||||||
|
public static PacketSnapshot PACKET_EMPTY_CHUNK;
|
||||||
|
|
||||||
public static PacketSnapshot PACKET_TITLE_TITLE;
|
public static PacketSnapshot PACKET_TITLE_TITLE;
|
||||||
public static PacketSnapshot PACKET_TITLE_SUBTITLE;
|
public static PacketSnapshot PACKET_TITLE_SUBTITLE;
|
||||||
@ -52,6 +53,7 @@ public final class PacketSnapshots {
|
|||||||
public static PacketSnapshot PACKET_TITLE_LEGACY_SUBTITLE;
|
public static PacketSnapshot PACKET_TITLE_LEGACY_SUBTITLE;
|
||||||
public static PacketSnapshot PACKET_TITLE_LEGACY_TIMES;
|
public static PacketSnapshot PACKET_TITLE_LEGACY_TIMES;
|
||||||
|
|
||||||
|
|
||||||
private PacketSnapshots() { }
|
private PacketSnapshots() { }
|
||||||
|
|
||||||
public static void initPackets(LimboServer server) {
|
public static void initPackets(LimboServer server) {
|
||||||
@ -108,6 +110,8 @@ public final class PacketSnapshots {
|
|||||||
|
|
||||||
PACKET_DECLARE_COMMANDS = PacketSnapshot.of(declareCommands);
|
PACKET_DECLARE_COMMANDS = PacketSnapshot.of(declareCommands);
|
||||||
|
|
||||||
|
PACKET_EMPTY_CHUNK = PacketSnapshot.of(new PacketEmptyChunk());
|
||||||
|
|
||||||
if (server.getConfig().isUseHeaderAndFooter()) {
|
if (server.getConfig().isUseHeaderAndFooter()) {
|
||||||
PacketPlayerListHeader header = new PacketPlayerListHeader();
|
PacketPlayerListHeader header = new PacketPlayerListHeader();
|
||||||
header.setHeader(server.getConfig().getPlayerListHeader());
|
header.setHeader(server.getConfig().getPlayerListHeader());
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
package ru.nanit.limbo.protocol.packets.play;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBufOutputStream;
|
||||||
|
import ru.nanit.limbo.protocol.ByteMessage;
|
||||||
|
import ru.nanit.limbo.protocol.PacketOut;
|
||||||
|
import ru.nanit.limbo.protocol.registry.Version;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class PacketEmptyChunk implements PacketOut {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void encode(ByteMessage msg, Version version) {
|
||||||
|
msg.writeInt(0);
|
||||||
|
msg.writeInt(0);
|
||||||
|
|
||||||
|
writeHeightmaps(msg, version.getProtocolNumber());
|
||||||
|
|
||||||
|
byte[] sectionData = new byte[]{0, 0, 0, 0, 0, 0, 1, 0};
|
||||||
|
msg.writeVarInt(sectionData.length * 16);
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
msg.writeBytes(sectionData);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.writeVarInt(0);
|
||||||
|
|
||||||
|
byte[] lightData = new byte[]{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 3, -1, -1, 0, 0};
|
||||||
|
msg.writeBytes(lightData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeHeightmaps(ByteMessage buf, int version) {
|
||||||
|
try (ByteBufOutputStream output = new ByteBufOutputStream(buf)) {
|
||||||
|
output.writeByte(10); //CompoundTag
|
||||||
|
output.writeUTF(""); // CompoundName
|
||||||
|
output.writeByte(10); //CompoundTag
|
||||||
|
output.writeUTF("root"); //root compound
|
||||||
|
output.writeByte(12); //long array
|
||||||
|
output.writeUTF("MOTION_BLOCKING");
|
||||||
|
long[] longArrayTag = new long[version < Version.V1_18.getProtocolNumber() ? 36 : 37];
|
||||||
|
output.writeInt(longArrayTag.length);
|
||||||
|
for (int i = 0, length = longArrayTag.length; i < length; i++) {
|
||||||
|
output.writeLong(longArrayTag[i]);
|
||||||
|
}
|
||||||
|
buf.writeByte(0); //end of compound
|
||||||
|
buf.writeByte(0); //end of compound
|
||||||
|
}
|
||||||
|
catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -101,7 +101,7 @@ public class PacketJoinGame implements PacketOut {
|
|||||||
|
|
||||||
if (version.fromTo(Version.V1_8, Version.V1_9_1)) {
|
if (version.fromTo(Version.V1_8, Version.V1_9_1)) {
|
||||||
msg.writeByte(gameMode);
|
msg.writeByte(gameMode);
|
||||||
msg.writeByte(dimensionRegistry.getDefaultDimension().getId());
|
msg.writeByte(dimensionRegistry.getDefaultDimension_1_16().getId());
|
||||||
msg.writeByte(0); // Difficulty
|
msg.writeByte(0); // Difficulty
|
||||||
msg.writeByte(maxPlayers);
|
msg.writeByte(maxPlayers);
|
||||||
msg.writeString("flat"); // Level type
|
msg.writeString("flat"); // Level type
|
||||||
@ -110,7 +110,7 @@ public class PacketJoinGame implements PacketOut {
|
|||||||
|
|
||||||
if (version.fromTo(Version.V1_9_2, Version.V1_13_2)) {
|
if (version.fromTo(Version.V1_9_2, Version.V1_13_2)) {
|
||||||
msg.writeByte(gameMode);
|
msg.writeByte(gameMode);
|
||||||
msg.writeInt(dimensionRegistry.getDefaultDimension().getId());
|
msg.writeInt(dimensionRegistry.getDefaultDimension_1_16().getId());
|
||||||
msg.writeByte(0); // Difficulty
|
msg.writeByte(0); // Difficulty
|
||||||
msg.writeByte(maxPlayers);
|
msg.writeByte(maxPlayers);
|
||||||
msg.writeString("flat"); // Level type
|
msg.writeString("flat"); // Level type
|
||||||
@ -119,7 +119,7 @@ public class PacketJoinGame implements PacketOut {
|
|||||||
|
|
||||||
if (version.fromTo(Version.V1_14, Version.V1_14_4)) {
|
if (version.fromTo(Version.V1_14, Version.V1_14_4)) {
|
||||||
msg.writeByte(gameMode);
|
msg.writeByte(gameMode);
|
||||||
msg.writeInt(dimensionRegistry.getDefaultDimension().getId());
|
msg.writeInt(dimensionRegistry.getDefaultDimension_1_16().getId());
|
||||||
msg.writeByte(maxPlayers);
|
msg.writeByte(maxPlayers);
|
||||||
msg.writeString("flat"); // Level type
|
msg.writeString("flat"); // Level type
|
||||||
msg.writeVarInt(viewDistance);
|
msg.writeVarInt(viewDistance);
|
||||||
@ -128,7 +128,7 @@ public class PacketJoinGame implements PacketOut {
|
|||||||
|
|
||||||
if (version.fromTo(Version.V1_15, Version.V1_15_2)) {
|
if (version.fromTo(Version.V1_15, Version.V1_15_2)) {
|
||||||
msg.writeByte(gameMode);
|
msg.writeByte(gameMode);
|
||||||
msg.writeInt(dimensionRegistry.getDefaultDimension().getId());
|
msg.writeInt(dimensionRegistry.getDefaultDimension_1_16().getId());
|
||||||
msg.writeLong(hashedSeed);
|
msg.writeLong(hashedSeed);
|
||||||
msg.writeByte(maxPlayers);
|
msg.writeByte(maxPlayers);
|
||||||
msg.writeString("flat"); // Level type
|
msg.writeString("flat"); // Level type
|
||||||
@ -142,7 +142,7 @@ public class PacketJoinGame implements PacketOut {
|
|||||||
msg.writeByte(previousGameMode);
|
msg.writeByte(previousGameMode);
|
||||||
msg.writeStringsArray(worldNames);
|
msg.writeStringsArray(worldNames);
|
||||||
msg.writeCompoundTag(dimensionRegistry.getOldCodec());
|
msg.writeCompoundTag(dimensionRegistry.getOldCodec());
|
||||||
msg.writeString(dimensionRegistry.getDefaultDimension().getName());
|
msg.writeString(dimensionRegistry.getDefaultDimension_1_16().getName());
|
||||||
msg.writeString(worldName);
|
msg.writeString(worldName);
|
||||||
msg.writeLong(hashedSeed);
|
msg.writeLong(hashedSeed);
|
||||||
msg.writeByte(maxPlayers);
|
msg.writeByte(maxPlayers);
|
||||||
@ -158,8 +158,8 @@ public class PacketJoinGame implements PacketOut {
|
|||||||
msg.writeByte(gameMode);
|
msg.writeByte(gameMode);
|
||||||
msg.writeByte(previousGameMode);
|
msg.writeByte(previousGameMode);
|
||||||
msg.writeStringsArray(worldNames);
|
msg.writeStringsArray(worldNames);
|
||||||
msg.writeCompoundTag(dimensionRegistry.getCodec());
|
msg.writeCompoundTag(dimensionRegistry.getCodec_1_16());
|
||||||
msg.writeCompoundTag(dimensionRegistry.getDefaultDimension().getData());
|
msg.writeCompoundTag(dimensionRegistry.getDefaultDimension_1_16().getData());
|
||||||
msg.writeString(worldName);
|
msg.writeString(worldName);
|
||||||
msg.writeLong(hashedSeed);
|
msg.writeLong(hashedSeed);
|
||||||
msg.writeVarInt(maxPlayers);
|
msg.writeVarInt(maxPlayers);
|
||||||
@ -175,8 +175,14 @@ public class PacketJoinGame implements PacketOut {
|
|||||||
msg.writeByte(gameMode);
|
msg.writeByte(gameMode);
|
||||||
msg.writeByte(previousGameMode);
|
msg.writeByte(previousGameMode);
|
||||||
msg.writeStringsArray(worldNames);
|
msg.writeStringsArray(worldNames);
|
||||||
msg.writeCompoundTag(dimensionRegistry.getCodec());
|
if (version.moreOrEqual(Version.V1_18_2)) {
|
||||||
msg.writeCompoundTag(dimensionRegistry.getDefaultDimension().getData());
|
msg.writeCompoundTag(dimensionRegistry.getCodec_1_18_2());
|
||||||
|
msg.writeCompoundTag(dimensionRegistry.getDefaultDimension_1_18_2().getData());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg.writeCompoundTag(dimensionRegistry.getCodec_1_16());
|
||||||
|
msg.writeCompoundTag(dimensionRegistry.getDefaultDimension_1_16().getData());
|
||||||
|
}
|
||||||
msg.writeString(worldName);
|
msg.writeString(worldName);
|
||||||
msg.writeLong(hashedSeed);
|
msg.writeLong(hashedSeed);
|
||||||
msg.writeVarInt(maxPlayers);
|
msg.writeVarInt(maxPlayers);
|
||||||
|
@ -84,7 +84,7 @@ public enum State {
|
|||||||
map(0x0E, V1_13, V1_13_2),
|
map(0x0E, V1_13, V1_13_2),
|
||||||
map(0x0F, V1_14, V1_15_2),
|
map(0x0F, V1_14, V1_15_2),
|
||||||
map(0x10, V1_16, V1_16_4),
|
map(0x10, V1_16, V1_16_4),
|
||||||
map(0x0F, V1_17, V1_18)
|
map(0x0F, V1_17, V1_18_2)
|
||||||
);
|
);
|
||||||
|
|
||||||
clientBound.register(PacketDeclareCommands::new,
|
clientBound.register(PacketDeclareCommands::new,
|
||||||
@ -92,7 +92,7 @@ public enum State {
|
|||||||
map(0x12, V1_15, V1_15_2),
|
map(0x12, V1_15, V1_15_2),
|
||||||
map(0x11, V1_16, V1_16_1),
|
map(0x11, V1_16, V1_16_1),
|
||||||
map(0x10, V1_16_2, V1_16_4),
|
map(0x10, V1_16_2, V1_16_4),
|
||||||
map(0x12, V1_17, V1_18)
|
map(0x12, V1_17, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketJoinGame::new,
|
clientBound.register(PacketJoinGame::new,
|
||||||
map(0x01, V1_8, V1_8),
|
map(0x01, V1_8, V1_8),
|
||||||
@ -101,7 +101,7 @@ public enum State {
|
|||||||
map(0x26, V1_15, V1_15_2),
|
map(0x26, V1_15, V1_15_2),
|
||||||
map(0x25, V1_16, V1_16_1),
|
map(0x25, V1_16, V1_16_1),
|
||||||
map(0x24, V1_16_2, V1_16_4),
|
map(0x24, V1_16_2, V1_16_4),
|
||||||
map(0x26, V1_17, V1_18)
|
map(0x26, V1_17, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketPluginMessage::new,
|
clientBound.register(PacketPluginMessage::new,
|
||||||
map(0x19, V1_13, V1_13_2),
|
map(0x19, V1_13, V1_13_2),
|
||||||
@ -109,7 +109,7 @@ public enum State {
|
|||||||
map(0x19, V1_15, V1_15_2),
|
map(0x19, V1_15, V1_15_2),
|
||||||
map(0x18, V1_16, V1_16_1),
|
map(0x18, V1_16, V1_16_1),
|
||||||
map(0x17, V1_16_2, V1_16_4),
|
map(0x17, V1_16_2, V1_16_4),
|
||||||
map(0x18, V1_17, V1_18)
|
map(0x18, V1_17, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketPlayerAbilities::new,
|
clientBound.register(PacketPlayerAbilities::new,
|
||||||
map(0x39, V1_8, V1_8),
|
map(0x39, V1_8, V1_8),
|
||||||
@ -120,7 +120,7 @@ public enum State {
|
|||||||
map(0x32, V1_15, V1_15_2),
|
map(0x32, V1_15, V1_15_2),
|
||||||
map(0x31, V1_16, V1_16_1),
|
map(0x31, V1_16, V1_16_1),
|
||||||
map(0x30, V1_16_2, V1_16_4),
|
map(0x30, V1_16_2, V1_16_4),
|
||||||
map(0x32, V1_17, V1_18)
|
map(0x32, V1_17, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketPlayerPositionAndLook::new,
|
clientBound.register(PacketPlayerPositionAndLook::new,
|
||||||
map(0x08, V1_8, V1_8),
|
map(0x08, V1_8, V1_8),
|
||||||
@ -131,7 +131,7 @@ public enum State {
|
|||||||
map(0x36, V1_15, V1_15_2),
|
map(0x36, V1_15, V1_15_2),
|
||||||
map(0x35, V1_16, V1_16_1),
|
map(0x35, V1_16, V1_16_1),
|
||||||
map(0x34, V1_16_2, V1_16_4),
|
map(0x34, V1_16_2, V1_16_4),
|
||||||
map(0x38, V1_17, V1_18)
|
map(0x38, V1_17, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketKeepAlive::new,
|
clientBound.register(PacketKeepAlive::new,
|
||||||
map(0x00, V1_8, V1_8),
|
map(0x00, V1_8, V1_8),
|
||||||
@ -141,7 +141,7 @@ public enum State {
|
|||||||
map(0x21, V1_15, V1_15_2),
|
map(0x21, V1_15, V1_15_2),
|
||||||
map(0x20, V1_16, V1_16_1),
|
map(0x20, V1_16, V1_16_1),
|
||||||
map(0x1F, V1_16_2, V1_16_4),
|
map(0x1F, V1_16_2, V1_16_4),
|
||||||
map(0x21, V1_17, V1_18)
|
map(0x21, V1_17, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketChatMessage::new,
|
clientBound.register(PacketChatMessage::new,
|
||||||
map(0x02, V1_8, V1_8),
|
map(0x02, V1_8, V1_8),
|
||||||
@ -149,13 +149,13 @@ public enum State {
|
|||||||
map(0x0E, V1_13, V1_14_4),
|
map(0x0E, V1_13, V1_14_4),
|
||||||
map(0x0F, V1_15, V1_15_2),
|
map(0x0F, V1_15, V1_15_2),
|
||||||
map(0x0E, V1_16, V1_16_4),
|
map(0x0E, V1_16, V1_16_4),
|
||||||
map(0x0F, V1_17, V1_18)
|
map(0x0F, V1_17, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketBossBar::new,
|
clientBound.register(PacketBossBar::new,
|
||||||
map(0x0C, V1_9, V1_14_4),
|
map(0x0C, V1_9, V1_14_4),
|
||||||
map(0x0D, V1_15, V1_15_2),
|
map(0x0D, V1_15, V1_15_2),
|
||||||
map(0x0C, V1_16, V1_16_4),
|
map(0x0C, V1_16, V1_16_4),
|
||||||
map(0x0D, V1_17, V1_18)
|
map(0x0D, V1_17, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketPlayerInfo::new,
|
clientBound.register(PacketPlayerInfo::new,
|
||||||
map(0x38, V1_8, V1_8),
|
map(0x38, V1_8, V1_8),
|
||||||
@ -166,7 +166,7 @@ public enum State {
|
|||||||
map(0x34, V1_15, V1_15_2),
|
map(0x34, V1_15, V1_15_2),
|
||||||
map(0x33, V1_16, V1_16_1),
|
map(0x33, V1_16, V1_16_1),
|
||||||
map(0x32, V1_16_2, V1_16_4),
|
map(0x32, V1_16_2, V1_16_4),
|
||||||
map(0x36, V1_17, V1_18)
|
map(0x36, V1_17, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketTitleLegacy::new,
|
clientBound.register(PacketTitleLegacy::new,
|
||||||
map(0x45, V1_8, V1_11_1),
|
map(0x45, V1_8, V1_11_1),
|
||||||
@ -179,15 +179,15 @@ public enum State {
|
|||||||
);
|
);
|
||||||
clientBound.register(PacketTitleSetTitle::new,
|
clientBound.register(PacketTitleSetTitle::new,
|
||||||
map(0x59, V1_17, V1_17_1),
|
map(0x59, V1_17, V1_17_1),
|
||||||
map(0x5A, V1_18, V1_18)
|
map(0x5A, V1_18, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketTitleSetSubTitle::new,
|
clientBound.register(PacketTitleSetSubTitle::new,
|
||||||
map(0x57, V1_17, V1_17_1),
|
map(0x57, V1_17, V1_17_1),
|
||||||
map(0x58, V1_18, V1_18)
|
map(0x58, V1_18, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketTitleTimes::new,
|
clientBound.register(PacketTitleTimes::new,
|
||||||
map(0x5A, V1_17, V1_17_1),
|
map(0x5A, V1_17, V1_17_1),
|
||||||
map(0x5B, V1_18, V1_18)
|
map(0x5B, V1_18, V1_18_2)
|
||||||
);
|
);
|
||||||
clientBound.register(PacketPlayerListHeader::new,
|
clientBound.register(PacketPlayerListHeader::new,
|
||||||
map(0x47, V1_8, V1_8),
|
map(0x47, V1_8, V1_8),
|
||||||
@ -200,7 +200,10 @@ public enum State {
|
|||||||
map(0x54, V1_15, V1_15_2),
|
map(0x54, V1_15, V1_15_2),
|
||||||
map(0x53, V1_16, V1_16_4),
|
map(0x53, V1_16, V1_16_4),
|
||||||
map(0x5E, V1_17, V1_17_1),
|
map(0x5E, V1_17, V1_17_1),
|
||||||
map(0x5F, V1_18, V1_18)
|
map(0x5F, V1_18, V1_18_2)
|
||||||
|
);
|
||||||
|
clientBound.register(PacketEmptyChunk::new,
|
||||||
|
map(0x22, V1_18, V1_18_2)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -56,8 +56,9 @@ public enum Version {
|
|||||||
// 1.16.5 has same protocol number
|
// 1.16.5 has same protocol number
|
||||||
V1_17(755),
|
V1_17(755),
|
||||||
V1_17_1(756),
|
V1_17_1(756),
|
||||||
V1_18(757);
|
V1_18(757),
|
||||||
// 1.18.1 has same protocol number
|
// 1.18.1 has same protocol number
|
||||||
|
V1_18_2(758);
|
||||||
|
|
||||||
private static final Map<Integer, Version> VERSION_MAP;
|
private static final Map<Integer, Version> VERSION_MAP;
|
||||||
private static final Version MAX;
|
private static final Version MAX;
|
||||||
|
@ -20,9 +20,10 @@ package ru.nanit.limbo.util;
|
|||||||
public final class Colors {
|
public final class Colors {
|
||||||
|
|
||||||
private static final char CHAR_FROM = '&';
|
private static final char CHAR_FROM = '&';
|
||||||
private static final char CHAR_TO = '§';
|
private static final char CHAR_TO = '\u00a7';
|
||||||
|
|
||||||
private Colors() {}
|
private Colors() {
|
||||||
|
}
|
||||||
|
|
||||||
public static String of(String text) {
|
public static String of(String text) {
|
||||||
if (text == null) return null;
|
if (text == null) return null;
|
||||||
|
@ -31,33 +31,49 @@ public final class DimensionRegistry {
|
|||||||
|
|
||||||
private final LimboServer server;
|
private final LimboServer server;
|
||||||
|
|
||||||
private Dimension defaultDimension;
|
private Dimension defaultDimension_1_16;
|
||||||
|
private Dimension defaultDimension_1_18_2;
|
||||||
|
|
||||||
private CompoundBinaryTag codec;
|
private CompoundBinaryTag codec_1_16;
|
||||||
|
private CompoundBinaryTag codec_1_18_2;
|
||||||
private CompoundBinaryTag oldCodec;
|
private CompoundBinaryTag oldCodec;
|
||||||
|
|
||||||
public DimensionRegistry(LimboServer server) {
|
public DimensionRegistry(LimboServer server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundBinaryTag getCodec() {
|
public CompoundBinaryTag getCodec_1_16() {
|
||||||
return codec;
|
return codec_1_16;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundBinaryTag getCodec_1_18_2() {
|
||||||
|
return codec_1_18_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundBinaryTag getOldCodec() {
|
public CompoundBinaryTag getOldCodec() {
|
||||||
return oldCodec;
|
return oldCodec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dimension getDefaultDimension() {
|
public Dimension getDefaultDimension_1_16() {
|
||||||
return defaultDimension;
|
return defaultDimension_1_16;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dimension getDefaultDimension_1_18_2() {
|
||||||
|
return defaultDimension_1_18_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(String def) throws IOException {
|
public void load(String def) throws IOException {
|
||||||
codec = readCodecFile("/dimension/codec_new.snbt");
|
codec_1_16 = readCodecFile("/dimension/codec_1_16.snbt");
|
||||||
|
codec_1_18_2 = readCodecFile("/dimension/codec_1_18_2.snbt");
|
||||||
// On 1.16-1.16.1 different codec format
|
// On 1.16-1.16.1 different codec format
|
||||||
oldCodec = readCodecFile("/dimension/codec_old.snbt");
|
oldCodec = readCodecFile("/dimension/codec_old.snbt");
|
||||||
|
|
||||||
ListBinaryTag dimensions = codec.getCompound("minecraft:dimension_type").getList("value");
|
defaultDimension_1_16 = getDefaultDimension(def, codec_1_16);
|
||||||
|
defaultDimension_1_18_2 = getDefaultDimension(def, codec_1_18_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dimension getDefaultDimension(String def, CompoundBinaryTag tag) {
|
||||||
|
ListBinaryTag dimensions = tag.getCompound("minecraft:dimension_type").getList("value");
|
||||||
|
|
||||||
CompoundBinaryTag overWorld = (CompoundBinaryTag) ((CompoundBinaryTag) dimensions.get(0)).get("element");
|
CompoundBinaryTag overWorld = (CompoundBinaryTag) ((CompoundBinaryTag) dimensions.get(0)).get("element");
|
||||||
CompoundBinaryTag nether = (CompoundBinaryTag) ((CompoundBinaryTag) dimensions.get(2)).get("element");
|
CompoundBinaryTag nether = (CompoundBinaryTag) ((CompoundBinaryTag) dimensions.get(2)).get("element");
|
||||||
@ -65,18 +81,14 @@ public final class DimensionRegistry {
|
|||||||
|
|
||||||
switch (def.toLowerCase()) {
|
switch (def.toLowerCase()) {
|
||||||
case "overworld":
|
case "overworld":
|
||||||
defaultDimension = new Dimension(0, "minecraft:overworld", overWorld);
|
return new Dimension(0, "minecraft:overworld", overWorld);
|
||||||
break;
|
|
||||||
case "nether":
|
case "nether":
|
||||||
defaultDimension = new Dimension(-1, "minecraft:nether", nether);
|
return new Dimension(-1, "minecraft:nether", nether);
|
||||||
break;
|
|
||||||
case "the_end":
|
case "the_end":
|
||||||
defaultDimension = new Dimension(1, "minecraft:the_end", theEnd);
|
return new Dimension(1, "minecraft:the_end", theEnd);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
defaultDimension = new Dimension(1, "minecraft:the_end", theEnd);
|
|
||||||
Logger.warning("Undefined dimension type: '%s'. Using THE_END as default", def);
|
Logger.warning("Undefined dimension type: '%s'. Using THE_END as default", def);
|
||||||
break;
|
return new Dimension(1, "minecraft:the_end", theEnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2093
src/main/resources/dimension/codec_1_18_2.snbt
Normal file
2093
src/main/resources/dimension/codec_1_18_2.snbt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user