Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 09:00:09 +01:00
Merge pull request #1680 from KennyTV/abstraction
Fix login packet reading on 1.16 servers, fix uuid nbt tags
Dieser Commit ist enthalten in:
Commit
c2a1d289e1
@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
@ -109,22 +110,29 @@ public class BaseProtocol1_7 extends Protocol {
|
||||
registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - UUID as String
|
||||
map(Type.STRING); // 1 - Player Username
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ProtocolInfo info = wrapper.user().get(ProtocolInfo.class);
|
||||
info.setState(State.PLAY);
|
||||
|
||||
if (info.getServerProtocolVersion() >= ProtocolVersion.v1_16.getId()) {
|
||||
// 1.16+ uses int arrays
|
||||
UUID uuid = wrapper.passthrough(Type.UUID_INT_ARRAY);
|
||||
info.setUuid(uuid);
|
||||
} else {
|
||||
// Save other info
|
||||
String stringUUID = wrapper.get(Type.STRING, 0);
|
||||
String stringUUID = wrapper.passthrough(Type.STRING);
|
||||
if (stringUUID.length() == 32) { // Trimmed UUIDs are 32 characters
|
||||
// Trimmed
|
||||
stringUUID = addDashes(stringUUID);
|
||||
}
|
||||
UUID uuid = UUID.fromString(stringUUID);
|
||||
info.setUuid(uuid);
|
||||
info.setUsername(wrapper.get(Type.STRING, 1));
|
||||
}
|
||||
|
||||
String username = wrapper.passthrough(Type.STRING);
|
||||
info.setUsername(username);
|
||||
// Add to ported clients
|
||||
Via.getManager().addPortedClient(wrapper.user());
|
||||
|
||||
@ -137,7 +145,7 @@ public class BaseProtocol1_7 extends Protocol {
|
||||
// Print out the route to console
|
||||
Via.getPlatform().getLogger().log(Level.INFO, "{0} logged in with protocol {1}, Route: {2}",
|
||||
new Object[]{
|
||||
wrapper.get(Type.STRING, 1),
|
||||
username,
|
||||
info.getProtocolVersion(),
|
||||
Joiner.on(", ").join(info.getPipeline().pipes(), ", ")
|
||||
});
|
||||
|
@ -1,16 +1,23 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.BlockRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.UUIDIntArrayType;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class WorldPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
@ -43,6 +50,34 @@ public class WorldPackets {
|
||||
section.setPaletteEntry(i, Protocol1_16To1_15_2.getNewBlockStateId(old));
|
||||
}
|
||||
}
|
||||
|
||||
if (chunk.getBlockEntities() == null) return;
|
||||
for (CompoundTag blockEntity : chunk.getBlockEntities()) {
|
||||
String id = ((StringTag) blockEntity.get("id")).getValue();
|
||||
if (id.equals("minecraft:conduit")) {
|
||||
StringTag targetUuidTag = blockEntity.remove("target_uuid");
|
||||
if (targetUuidTag == null) continue;
|
||||
|
||||
|
||||
// target_uuid -> Target
|
||||
UUID targetUuid = UUID.fromString(targetUuidTag.getValue());
|
||||
blockEntity.put(new IntArrayTag("Target", UUIDIntArrayType.uuidToIntArray(targetUuid)));
|
||||
} else if (id.equals("minecraft:skull")) {
|
||||
CompoundTag ownerTag = blockEntity.remove("Owner");
|
||||
if (ownerTag == null) continue;
|
||||
|
||||
StringTag ownerUuidTag = ownerTag.remove("Id");
|
||||
UUID ownerUuid = UUID.fromString(ownerUuidTag.getValue());
|
||||
ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(ownerUuid)));
|
||||
|
||||
// Owner -> SkullOwner
|
||||
CompoundTag skullOwnerTag = new CompoundTag("SkullOwner");
|
||||
for (Tag tag : ownerTag) {
|
||||
skullOwnerTag.put(tag);
|
||||
}
|
||||
blockEntity.put(skullOwnerTag);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -57,7 +92,7 @@ public class WorldPackets {
|
||||
|
||||
public static int getNewParticleId(int id) {
|
||||
if (id >= 27) {
|
||||
id += 1; // soul flame
|
||||
id += 2; // soul flame, soul
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren