forked from BLOCKFANTASY/LOOHP-Limbo
Minecraft 1.21.3
This commit is contained in:
@@ -132,8 +132,8 @@ public final class Limbo {
|
||||
|
||||
//===========================
|
||||
|
||||
public final String SERVER_IMPLEMENTATION_VERSION = "1.21.1";
|
||||
public final int SERVER_IMPLEMENTATION_PROTOCOL = 767;
|
||||
public final String SERVER_IMPLEMENTATION_VERSION = "1.21.3";
|
||||
public final int SERVER_IMPLEMENTATION_PROTOCOL = 768;
|
||||
public final String LIMBO_IMPLEMENTATION_VERSION;
|
||||
|
||||
private final AtomicBoolean isRunning;
|
||||
|
||||
@@ -498,7 +498,7 @@ public class ClientConnection extends Thread {
|
||||
break;
|
||||
}
|
||||
|
||||
PacketLoginOutLoginSuccess success = new PacketLoginOutLoginSuccess(uuid, username, false);
|
||||
PacketLoginOutLoginSuccess success = new PacketLoginOutLoginSuccess(uuid, username);
|
||||
sendPacket(success);
|
||||
|
||||
player = new Player(this, username, uuid, Limbo.getInstance().getNextEntityId(), Limbo.getInstance().getServerProperties().getWorldSpawn(), new PlayerInteractManager());
|
||||
@@ -522,7 +522,7 @@ public class ClientConnection extends Thread {
|
||||
inetAddress = InetAddress.getByName(data.getIpAddress());
|
||||
forwardedSkin = data.getSkinResponse();
|
||||
|
||||
PacketLoginOutLoginSuccess success = new PacketLoginOutLoginSuccess(data.getUuid(), data.getUsername(), false);
|
||||
PacketLoginOutLoginSuccess success = new PacketLoginOutLoginSuccess(data.getUuid(), data.getUsername());
|
||||
sendPacket(success);
|
||||
|
||||
player = new Player(this, data.getUsername(), data.getUuid(), Limbo.getInstance().getNextEntityId(), Limbo.getInstance().getServerProperties().getWorldSpawn(), new PlayerInteractManager());
|
||||
@@ -572,7 +572,7 @@ public class ClientConnection extends Thread {
|
||||
worldSpawn = spawnEvent.getSpawnLocation();
|
||||
World world = worldSpawn.getWorld();
|
||||
|
||||
PacketPlayOutLogin join = new PacketPlayOutLogin(player.getEntityId(), false, Limbo.getInstance().getWorlds(), properties.getMaxPlayers(), 8, 8, properties.isReducedDebugInfo(), true, false, world.getEnvironment(), world, 0, properties.getDefaultGamemode(), false, true, 0, false);
|
||||
PacketPlayOutLogin join = new PacketPlayOutLogin(player.getEntityId(), false, Limbo.getInstance().getWorlds(), properties.getMaxPlayers(), 8, 8, properties.isReducedDebugInfo(), true, false, world.getEnvironment(), world, 0, properties.getDefaultGamemode(), false, true, 0, 0, false);
|
||||
sendPacket(join);
|
||||
Limbo.getInstance().getUnsafe().a(player, properties.getDefaultGamemode());
|
||||
|
||||
|
||||
+1
-8
@@ -32,12 +32,10 @@ public class PacketLoginOutLoginSuccess extends PacketOut {
|
||||
|
||||
private final UUID uuid;
|
||||
private final String username;
|
||||
private final boolean strictErrorHandling;
|
||||
|
||||
public PacketLoginOutLoginSuccess(UUID uuid, String username, boolean strictErrorHandling) {
|
||||
public PacketLoginOutLoginSuccess(UUID uuid, String username) {
|
||||
this.uuid = uuid;
|
||||
this.username = username;
|
||||
this.strictErrorHandling = strictErrorHandling;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
@@ -48,10 +46,6 @@ public class PacketLoginOutLoginSuccess extends PacketOut {
|
||||
return username;
|
||||
}
|
||||
|
||||
public boolean isStrictErrorHandling() {
|
||||
return strictErrorHandling;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serializePacket() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
@@ -61,7 +55,6 @@ public class PacketLoginOutLoginSuccess extends PacketOut {
|
||||
DataTypeIO.writeUUID(output, uuid);
|
||||
DataTypeIO.writeString(output, username, StandardCharsets.UTF_8);
|
||||
DataTypeIO.writeVarInt(output, 0);
|
||||
output.writeBoolean(strictErrorHandling);
|
||||
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
|
||||
@@ -51,9 +51,10 @@ public class PacketPlayOutLogin extends PacketOut {
|
||||
private final boolean isDebug;
|
||||
private final boolean isFlat;
|
||||
private final int portalCooldown;
|
||||
private final int seaLevel;
|
||||
private final boolean enforcesSecureChat;
|
||||
|
||||
public PacketPlayOutLogin(int entityId, boolean isHardcore, List<World> worlds, int maxPlayers, int viewDistance, int simulationDistance, boolean reducedDebugInfo, boolean enableRespawnScreen, boolean doLimitedCrafting, Environment dimension, World world, long hashedSeed, GameMode gamemode, boolean isDebug, boolean isFlat, int portalCooldown, boolean enforcesSecureChat) {
|
||||
public PacketPlayOutLogin(int entityId, boolean isHardcore, List<World> worlds, int maxPlayers, int viewDistance, int simulationDistance, boolean reducedDebugInfo, boolean enableRespawnScreen, boolean doLimitedCrafting, Environment dimension, World world, long hashedSeed, GameMode gamemode, boolean isDebug, boolean isFlat, int portalCooldown, int seaLevel, boolean enforcesSecureChat) {
|
||||
this.entityId = entityId;
|
||||
this.isHardcore = isHardcore;
|
||||
this.worlds = worlds;
|
||||
@@ -70,6 +71,7 @@ public class PacketPlayOutLogin extends PacketOut {
|
||||
this.isDebug = isDebug;
|
||||
this.isFlat = isFlat;
|
||||
this.portalCooldown = portalCooldown;
|
||||
this.seaLevel = seaLevel;
|
||||
this.enforcesSecureChat = enforcesSecureChat;
|
||||
}
|
||||
|
||||
@@ -137,6 +139,10 @@ public class PacketPlayOutLogin extends PacketOut {
|
||||
return portalCooldown;
|
||||
}
|
||||
|
||||
public int getSeaLevel() {
|
||||
return seaLevel;
|
||||
}
|
||||
|
||||
public boolean isEnforcesSecureChat() {
|
||||
return enforcesSecureChat;
|
||||
}
|
||||
@@ -168,6 +174,7 @@ public class PacketPlayOutLogin extends PacketOut {
|
||||
output.writeBoolean(isFlat);
|
||||
output.writeBoolean(false);
|
||||
DataTypeIO.writeVarInt(output, portalCooldown);
|
||||
DataTypeIO.writeVarInt(output, seaLevel);
|
||||
output.writeBoolean(enforcesSecureChat);
|
||||
|
||||
return buffer.toByteArray();
|
||||
|
||||
+66
-28
@@ -26,26 +26,67 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class PacketPlayOutPositionAndLook extends PacketOut {
|
||||
|
||||
public enum PlayerTeleportFlags {
|
||||
X((byte) 0x01),
|
||||
Y((byte) 0x02),
|
||||
Z((byte) 0x04),
|
||||
Y_ROT((byte) 0x08),
|
||||
X_ROT((byte) 0x10);
|
||||
|
||||
private final byte bit;
|
||||
|
||||
PlayerTeleportFlags(byte bit) {
|
||||
this.bit = bit;
|
||||
|
||||
public enum Relative {
|
||||
|
||||
X(0), Y(1), Z(2), Y_ROT(3), X_ROT(4), DELTA_X(5), DELTA_Y(6), DELTA_Z(7), ROTATE_DELTA(8);
|
||||
|
||||
public static final Set<Relative> ALL = new LinkedHashSet<>(Arrays.asList(values()));
|
||||
public static final Set<Relative> ROTATION = Stream.of(Relative.X_ROT, Relative.Y_ROT).collect(Collectors.toSet());
|
||||
public static final Set<Relative> DELTA = Stream.of(Relative.DELTA_X, Relative.DELTA_Y, Relative.DELTA_Z, Relative.ROTATE_DELTA).collect(Collectors.toSet());
|
||||
|
||||
private final int bit;
|
||||
|
||||
@SafeVarargs
|
||||
public static Set<Relative> union(Set<Relative>... aset) {
|
||||
HashSet<Relative> hashset = new HashSet<>();
|
||||
int i = aset.length;
|
||||
for (Set<Relative> set : aset) {
|
||||
hashset.addAll(set);
|
||||
}
|
||||
return hashset;
|
||||
}
|
||||
|
||||
public byte getBit() {
|
||||
return bit;
|
||||
|
||||
Relative(final int i) {
|
||||
this.bit = i;
|
||||
}
|
||||
|
||||
private int getMask() {
|
||||
return 1 << this.bit;
|
||||
}
|
||||
|
||||
private boolean isSet(int i) {
|
||||
return (i & this.getMask()) == this.getMask();
|
||||
}
|
||||
|
||||
public static Set<Relative> unpack(int i) {
|
||||
Set<Relative> set = EnumSet.noneOf(Relative.class);
|
||||
Relative[] arelative = values();
|
||||
int j = arelative.length;
|
||||
for (Relative relative : arelative) {
|
||||
if (relative.isSet(i)) {
|
||||
set.add(relative);
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
public static int pack(Set<Relative> set) {
|
||||
int i = 0;
|
||||
Relative relative;
|
||||
for (Iterator<Relative> iterator = set.iterator(); iterator.hasNext(); i |= relative.getMask()) {
|
||||
relative = iterator.next();
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,17 +95,17 @@ public class PacketPlayOutPositionAndLook extends PacketOut {
|
||||
private final double z;
|
||||
private final float yaw;
|
||||
private final float pitch;
|
||||
private final Set<PlayerTeleportFlags> flags;
|
||||
private final Set<Relative> relatives;
|
||||
private final int teleportId;
|
||||
|
||||
public PacketPlayOutPositionAndLook(double x, double y, double z, float yaw, float pitch, int teleportId, PlayerTeleportFlags... flags) {
|
||||
public PacketPlayOutPositionAndLook(double x, double y, double z, float yaw, float pitch, int teleportId, Relative... relatives) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
this.teleportId = teleportId;
|
||||
this.flags = new HashSet<>(Arrays.asList(flags));
|
||||
this.relatives = new HashSet<>(Arrays.asList(relatives));
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
@@ -87,8 +128,8 @@ public class PacketPlayOutPositionAndLook extends PacketOut {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public Set<PlayerTeleportFlags> getFlags() {
|
||||
return flags;
|
||||
public Set<Relative> getRelatives() {
|
||||
return relatives;
|
||||
}
|
||||
|
||||
public int getTeleportId() {
|
||||
@@ -101,19 +142,16 @@ public class PacketPlayOutPositionAndLook extends PacketOut {
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(PacketRegistry.getPacketId(getClass()));
|
||||
DataTypeIO.writeVarInt(output, teleportId);
|
||||
output.writeDouble(x);
|
||||
output.writeDouble(y);
|
||||
output.writeDouble(z);
|
||||
output.writeDouble(0);
|
||||
output.writeDouble(0);
|
||||
output.writeDouble(0);
|
||||
output.writeFloat(yaw);
|
||||
output.writeFloat(pitch);
|
||||
|
||||
byte flag = 0;
|
||||
for (PlayerTeleportFlags each : flags) {
|
||||
flag = (byte) (flag | each.getBit());
|
||||
}
|
||||
|
||||
output.writeByte(flag);
|
||||
DataTypeIO.writeVarInt(output, teleportId);
|
||||
output.writeInt(Relative.pack(relatives));
|
||||
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class PacketRegistry {
|
||||
registerClass(PacketLoginInPluginMessaging.class, "minecraft:custom_query_answer", NetworkPhase.LOGIN, PacketBound.SERVERBOUND);
|
||||
registerClass(ServerboundLoginAcknowledgedPacket.class, "minecraft:login_acknowledged", NetworkPhase.LOGIN, PacketBound.SERVERBOUND);
|
||||
|
||||
registerClass(PacketLoginOutLoginSuccess.class, "minecraft:game_profile", NetworkPhase.LOGIN, PacketBound.CLIENTBOUND);
|
||||
registerClass(PacketLoginOutLoginSuccess.class, "minecraft:login_finished", NetworkPhase.LOGIN, PacketBound.CLIENTBOUND);
|
||||
registerClass(PacketLoginOutDisconnect.class, "minecraft:login_disconnect", NetworkPhase.LOGIN, PacketBound.CLIENTBOUND);
|
||||
registerClass(PacketLoginOutPluginMessaging.class, "minecraft:custom_query", NetworkPhase.LOGIN, PacketBound.CLIENTBOUND);
|
||||
|
||||
|
||||
@@ -42,16 +42,10 @@ public class RegistryCustom {
|
||||
|
||||
private static final Map<Key, RegistryCustom> REGISTRIES = new HashMap<>();
|
||||
|
||||
public static final RegistryCustom ADVANCEMENT = register("advancement");
|
||||
public static final RegistryCustom BANNER_PATTERN = register("banner_pattern");
|
||||
public static final RegistryCustom CHAT_TYPE = register("chat_type");
|
||||
public static final RegistryCustom DAMAGE_TYPE = register("damage_type");
|
||||
public static final RegistryCustom DIMENSION_TYPE = register("dimension_type");
|
||||
public static final RegistryCustom ENCHANTMENT = register("enchantment");
|
||||
public static final RegistryCustom JUKEBOX_SONG = register("jukebox_song");
|
||||
public static final RegistryCustom PAINTING_VARIANT = register("painting_variant");
|
||||
public static final RegistryCustom TRIM_MATERIAL = register("trim_material");
|
||||
public static final RegistryCustom TRIM_PATTERN = register("trim_pattern");
|
||||
public static final RegistryCustom WOLF_VARIANT = register("wolf_variant");
|
||||
public static final RegistryCustom WORLDGEN_BIOME = register("worldgen/biome");
|
||||
|
||||
|
||||
@@ -19,17 +19,11 @@
|
||||
|
||||
package com.loohp.limbo.utils;
|
||||
|
||||
import net.querz.nbt.tag.ByteTag;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import net.querz.nbt.tag.DoubleTag;
|
||||
import net.querz.nbt.tag.ListTag;
|
||||
import net.querz.nbt.tag.LongTag;
|
||||
import net.querz.nbt.tag.StringTag;
|
||||
import net.querz.nbt.tag.Tag;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CustomNBTUtils {
|
||||
|
||||
public static CompoundTag getCompoundTagFromJson(JSONObject json) {
|
||||
@@ -57,35 +51,16 @@ public class CustomNBTUtils {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ExtractMethodRecommender")
|
||||
public static ListTag<?> getListTagFromJson(JSONArray json) {
|
||||
public static ListTag<?> getListTagFromJson(JSONArray json) {
|
||||
if (json.isEmpty()) {
|
||||
return new ListTag<>(StringTag.class);
|
||||
return ListTag.createUnchecked(null);
|
||||
}
|
||||
Object firstValue = json.get(0);
|
||||
Class<? extends Tag> type;
|
||||
if (firstValue instanceof JSONObject) {
|
||||
type = CompoundTag.class;
|
||||
} else if (firstValue instanceof JSONArray) {
|
||||
type = ListTag.class;
|
||||
} else if (firstValue instanceof Boolean) {
|
||||
type = ByteTag.class;
|
||||
} else if (firstValue instanceof Long) {
|
||||
type = LongTag.class;
|
||||
} else if (firstValue instanceof Double) {
|
||||
type = DoubleTag.class;
|
||||
} else if (firstValue instanceof String) {
|
||||
type = StringTag.class;
|
||||
} else {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
ListTag<?> listTag = ListTag.createUnchecked(type);
|
||||
ListTag<?> listTag = ListTag.createUnchecked(null);
|
||||
for (Object rawValue : json) {
|
||||
if (rawValue instanceof JSONObject) {
|
||||
listTag.asCompoundTagList().add(getCompoundTagFromJson((JSONObject) rawValue));
|
||||
listTag.addUnchecked(getCompoundTagFromJson((JSONObject) rawValue));
|
||||
} else if (rawValue instanceof JSONArray) {
|
||||
listTag.asListTagList().add(getListTagFromJson((JSONArray) rawValue));
|
||||
listTag.addUnchecked(getListTagFromJson((JSONArray) rawValue));
|
||||
} else if (rawValue instanceof Boolean) {
|
||||
listTag.addBoolean((boolean) rawValue);
|
||||
} else if (rawValue instanceof Long) {
|
||||
|
||||
Reference in New Issue
Block a user