forked from BLOCKFANTASY/LOOHP-Limbo
Minecraft 1.21.3
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user