3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 09:00:09 +01:00
Dieser Commit ist enthalten in:
KennyTV 2020-05-29 15:14:18 +02:00
Ursprung bea01bc794
Commit a9e2544188
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 30 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -80,7 +80,7 @@ public class ProtocolVersion {
register(v1_15 = new ProtocolVersion(573, "1.15")); register(v1_15 = new ProtocolVersion(573, "1.15"));
register(v1_15_1 = new ProtocolVersion(575, "1.15.1")); register(v1_15_1 = new ProtocolVersion(575, "1.15.1"));
register(v1_15_2 = new ProtocolVersion(578, "1.15.2")); register(v1_15_2 = new ProtocolVersion(578, "1.15.2"));
register(v1_16 = new ProtocolVersion(718, "1.16")); register(v1_16 = new ProtocolVersion(719, "1.16"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN")); register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
} }

Datei anzeigen

@ -7,6 +7,7 @@ import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.entities.Entity1_16Types; import us.myles.ViaVersion.api.entities.Entity1_16Types;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
@ -20,23 +21,29 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class EntityPackets { public class EntityPackets {
private static final ValueTransformer<Integer, String> DIMENSION_TRANSFORMER = new ValueTransformer<Integer, String>(Type.INT, Type.STRING) { private static final PacketHandler DIMENSION_HANDLER = wrapper -> {
@Override int dimension = wrapper.read(Type.INT);
public String transform(PacketWrapper wrapper, Integer input) throws Exception { String dimensionName;
switch (input) { switch (dimension) {
case -1: case -1:
return "the_nether"; dimensionName = "minecraft:the_nether";
case 0: break;
return "overworld"; case 0:
case 1: dimensionName = "minecraft:overworld";
return "the_end"; break;
default: case 1:
Via.getPlatform().getLogger().warning("Invalid dimension id: " + input); dimensionName = "minecraft:the_end";
return "overworld"; break;
} default:
Via.getPlatform().getLogger().warning("Invalid dimension id: " + dimension);
dimensionName = "minecraft:overworld";
} }
wrapper.write(Type.STRING, dimensionName); // dimension type
wrapper.write(Type.STRING, dimensionName); // dimension
}; };
private static final CompoundTag DIMENSIONS_TAG = new CompoundTag(""); private static final CompoundTag DIMENSIONS_TAG = new CompoundTag("");
private static final String[] STRINGS = new String[0];
static { static {
ListTag list = new ListTag("dimension", CompoundTag.class); ListTag list = new ListTag("dimension", CompoundTag.class);
@ -75,7 +82,7 @@ public class EntityPackets {
protocol.registerOutgoing(State.PLAY, 0x3B, 0x3B, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x3B, 0x3B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(DIMENSION_TRANSFORMER); handler(DIMENSION_HANDLER);
map(Type.LONG); map(Type.LONG);
map(Type.UNSIGNED_BYTE); map(Type.UNSIGNED_BYTE);
handler(wrapper -> { handler(wrapper -> {
@ -97,13 +104,19 @@ public class EntityPackets {
public void registerMap() { public void registerMap() {
map(Type.INT); // Entity ID map(Type.INT); // Entity ID
map(Type.UNSIGNED_BYTE); // Gamemode map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.NOTHING, new ValueTransformer<Void, String[]>(Type.STRING_ARRAY) { // World list
@Override
public String[] transform(PacketWrapper wrapper, Void input) throws Exception {
return STRINGS;
}
});
map(Type.NOTHING, new ValueTransformer<Void, CompoundTag>(Type.NBT) { // whatever this is map(Type.NOTHING, new ValueTransformer<Void, CompoundTag>(Type.NBT) { // whatever this is
@Override @Override
public CompoundTag transform(PacketWrapper wrapper, Void input) throws Exception { public CompoundTag transform(PacketWrapper wrapper, Void input) throws Exception {
return DIMENSIONS_TAG; return DIMENSIONS_TAG;
} }
}); });
map(DIMENSION_TRANSFORMER); // Dimension handler(DIMENSION_HANDLER); // Dimension
map(Type.LONG); // Seed map(Type.LONG); // Seed
map(Type.UNSIGNED_BYTE); // Max players map(Type.UNSIGNED_BYTE); // Max players
handler(wrapper -> { handler(wrapper -> {