3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Current WIP 20w49a

Dieser Commit ist enthalten in:
KennyTV 2020-12-02 21:57:32 +01:00
Ursprung 6882678bc4
Commit 8a11b577eb
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
18 geänderte Dateien mit 1019 neuen und 713 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.3.0-20w48a</version> <version>3.3.0-20w49a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.3.0-20w48a</version> <version>3.3.0-20w49a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.3.0-20w48a</version> <version>3.3.0-20w49a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.3.0-20w48a</version> <version>3.3.0-20w49a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -54,7 +54,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_16_2 = register(751, "1.16.2"); public static final ProtocolVersion v1_16_2 = register(751, "1.16.2");
public static final ProtocolVersion v1_16_3 = register(753, "1.16.3"); public static final ProtocolVersion v1_16_3 = register(753, "1.16.3");
public static final ProtocolVersion v1_16_4 = register(754, "1.16.4"); public static final ProtocolVersion v1_16_4 = register(754, "1.16.4");
public static final ProtocolVersion v1_17 = register(755, 7, "1.17"); public static final ProtocolVersion v1_17 = register(755, 8, "1.17");
public static final ProtocolVersion unknown = register(-1, "UNKNOWN"); public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
public static ProtocolVersion register(int version, String name) { public static ProtocolVersion register(int version, String name) {

Datei anzeigen

@ -17,6 +17,7 @@ import us.myles.ViaVersion.api.type.types.ComponentType;
import us.myles.ViaVersion.api.type.types.DoubleType; import us.myles.ViaVersion.api.type.types.DoubleType;
import us.myles.ViaVersion.api.type.types.FloatType; import us.myles.ViaVersion.api.type.types.FloatType;
import us.myles.ViaVersion.api.type.types.IntType; import us.myles.ViaVersion.api.type.types.IntType;
import us.myles.ViaVersion.api.type.types.LongArrayType;
import us.myles.ViaVersion.api.type.types.LongType; import us.myles.ViaVersion.api.type.types.LongType;
import us.myles.ViaVersion.api.type.types.RemainingBytesType; import us.myles.ViaVersion.api.type.types.RemainingBytesType;
import us.myles.ViaVersion.api.type.types.ShortType; import us.myles.ViaVersion.api.type.types.ShortType;
@ -91,12 +92,13 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
@Deprecated @Deprecated
public static final Type<Double[]> DOUBLE_ARRAY = new ArrayType<>(Type.DOUBLE); public static final Type<Double[]> DOUBLE_ARRAY = new ArrayType<>(Type.DOUBLE);
public static final Type<Long> LONG = new LongType(); public static final LongType LONG = new LongType();
/** /**
* @deprecated unreasonable overhead * @deprecated unreasonable overhead
*/ */
@Deprecated @Deprecated
public static final Type<Long[]> LONG_ARRAY = new ArrayType<>(Type.LONG); public static final Type<Long[]> LONG_ARRAY = new ArrayType<>(Type.LONG);
public static final Type<long[]> LONG_ARRAY_PRIMITIVE = new LongArrayType();
public static final FloatType FLOAT = new FloatType(); public static final FloatType FLOAT = new FloatType();
/** /**

Datei anzeigen

@ -0,0 +1,29 @@
package us.myles.ViaVersion.api.type.types;
import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.api.type.Type;
public class LongArrayType extends Type<long[]> {
public LongArrayType() {
super(long[].class);
}
@Override
public long[] read(ByteBuf buffer) throws Exception {
int length = Type.VAR_INT.readPrimitive(buffer);
long[] array = new long[length];
for (int i = 0; i < array.length; i++) {
array[i] = Type.LONG.readPrimitive(buffer);
}
return array;
}
@Override
public void write(ByteBuf buffer, long[] object) throws Exception {
Type.VAR_INT.writePrimitive(buffer, object.length);
for (long l : object) {
Type.LONG.writePrimitive(buffer, l);
}
}
}

Datei anzeigen

@ -5,21 +5,29 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.TypeConverter; import us.myles.ViaVersion.api.type.TypeConverter;
public class LongType extends Type<Long> implements TypeConverter<Long> { public class LongType extends Type<Long> implements TypeConverter<Long> {
public LongType() { public LongType() {
super(Long.class); super(Long.class);
} }
/**
* @deprecated use {@link #readPrimitive(ByteBuf)} for manual reading to avoid wrapping
*/
@Override @Override
@Deprecated
public Long read(ByteBuf buffer) { public Long read(ByteBuf buffer) {
return buffer.readLong(); return buffer.readLong();
} }
/**
* @deprecated use {@link #readPrimitive(ByteBuf)} for manual reading to avoid wrapping
*/
@Override @Override
@Deprecated
public void write(ByteBuf buffer, Long object) { public void write(ByteBuf buffer, Long object) {
buffer.writeLong(object); buffer.writeLong(object);
} }
@Override @Override
public Long from(Object o) { public Long from(Object o) {
if (o instanceof Number) { if (o instanceof Number) {
@ -30,4 +38,12 @@ public class LongType extends Type<Long> implements TypeConverter<Long> {
} }
return (Long) o; return (Long) o;
} }
public long readPrimitive(ByteBuf buffer) {
return buffer.readLong();
}
public void writePrimitive(ByteBuf buffer, long object) {
buffer.writeLong(object);
}
} }

Datei anzeigen

@ -0,0 +1,100 @@
package us.myles.ViaVersion.protocols.protocol1_17to1_16_4;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
public enum ClientboundPackets1_17 implements ClientboundPacketType {
SPAWN_ENTITY, // 0x00
SPAWN_EXPERIENCE_ORB, // 0x01
SPAWN_MOB, // 0x02
SPAWN_PAINTING, // 0x03
SPAWN_PLAYER, // 0x04
ADD_VIBRATION_SIGNAL, // 0x05
ENTITY_ANIMATION, // 0x06
STATISTICS, // 0x07
ACKNOWLEDGE_PLAYER_DIGGING, // 0x08
BLOCK_BREAK_ANIMATION, // 0x09
BLOCK_ENTITY_DATA, // 0x0A
BLOCK_ACTION, // 0x0B
BLOCK_CHANGE, // 0x0C
BOSSBAR, // 0x0D
SERVER_DIFFICULTY, // 0x0E
CHAT_MESSAGE, // 0x0F
TAB_COMPLETE, // 0x10
DECLARE_COMMANDS, // 0x11
WINDOW_CONFIRMATION, // 0x12
CLOSE_WINDOW, // 0x13
WINDOW_ITEMS, // 0x14
WINDOW_PROPERTY, // 0x15
SET_SLOT, // 0x16
COOLDOWN, // 0x17
PLUGIN_MESSAGE, // 0x18
NAMED_SOUND, // 0x19
DISCONNECT, // 0x1A
ENTITY_STATUS, // 0x1B
EXPLOSION, // 0x1C
UNLOAD_CHUNK, // 0x1D
GAME_EVENT, // 0x1E
OPEN_HORSE_WINDOW, // 0x1F
KEEP_ALIVE, // 0x20
CHUNK_DATA, // 0x21
EFFECT, // 0x22
SPAWN_PARTICLE, // 0x23
UPDATE_LIGHT, // 0x24
JOIN_GAME, // 0x25
MAP_DATA, // 0x26
TRADE_LIST, // 0x27
ENTITY_POSITION, // 0x28
ENTITY_POSITION_AND_ROTATION, // 0x29
ENTITY_ROTATION, // 0x2A
ENTITY_MOVEMENT, // 0x2B
VEHICLE_MOVE, // 0x2C
OPEN_BOOK, // 0x2D
OPEN_WINDOW, // 0x2E
OPEN_SIGN_EDITOR, // 0x2F
CRAFT_RECIPE_RESPONSE, // 0x30
PLAYER_ABILITIES, // 0x31
COMBAT_EVENT, // 0x32
PLAYER_INFO, // 0x33
FACE_PLAYER, // 0x34
PLAYER_POSITION, // 0x35
UNLOCK_RECIPES, // 0x36
DESTROY_ENTITIES, // 0x37
REMOVE_ENTITY_EFFECT, // 0x38
RESOURCE_PACK, // 0x39
RESPAWN, // 0x3A
ENTITY_HEAD_LOOK, // 0x3B
MULTI_BLOCK_CHANGE, // 0x3C
SELECT_ADVANCEMENTS_TAB, // 0x3D
WORLD_BORDER, // 0x3E
CAMERA, // 0x3F
HELD_ITEM_CHANGE, // 0x40
UPDATE_VIEW_POSITION, // 0x41
UPDATE_VIEW_DISTANCE, // 0x42
SPAWN_POSITION, // 0x43
DISPLAY_SCOREBOARD, // 0x44
ENTITY_METADATA, // 0x45
ATTACH_ENTITY, // 0x46
ENTITY_VELOCITY, // 0x47
ENTITY_EQUIPMENT, // 0x48
SET_EXPERIENCE, // 0x49
UPDATE_HEALTH, // 0x4A
SCOREBOARD_OBJECTIVE, // 0x4B
SET_PASSENGERS, // 0x4C
TEAMS, // 0x4D
UPDATE_SCORE, // 0x4E
TIME_UPDATE, // 0x4F
TITLE, // 0x50
ENTITY_SOUND, // 0x51
SOUND, // 0x52
STOP_SOUND, // 0x53
TAB_LIST, // 0x54
NBT_QUERY, // 0x55
COLLECT_ITEM, // 0x56
ENTITY_TELEPORT, // 0x57
ADVANCEMENTS, // 0x58
ENTITY_PROPERTIES, // 0x59
ENTITY_EFFECT, // 0x5A
DECLARE_RECIPES, // 0x5B
TAGS, // 0x5C
}

Datei anzeigen

@ -19,13 +19,13 @@ import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.packets.WorldPackets;
import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage.BiomeStorage; import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage.BiomeStorage;
import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage.EntityTracker1_17; import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage.EntityTracker1_17;
public class Protocol1_17To1_16_4 extends Protocol<ClientboundPackets1_16_2, ClientboundPackets1_16_2, ServerboundPackets1_16_2, ServerboundPackets1_16_2> { public class Protocol1_17To1_16_4 extends Protocol<ClientboundPackets1_16_2, ClientboundPackets1_17, ServerboundPackets1_16_2, ServerboundPackets1_16_2> {
public static final MappingData MAPPINGS = new MappingData("1.16.2", "1.17", true); public static final MappingData MAPPINGS = new MappingData("1.16.2", "1.17", true);
private TagRewriter tagRewriter; private TagRewriter tagRewriter;
public Protocol1_17To1_16_4() { public Protocol1_17To1_16_4() {
super(ClientboundPackets1_16_2.class, ClientboundPackets1_16_2.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16_2.class); super(ClientboundPackets1_16_2.class, ClientboundPackets1_17.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16_2.class);
} }
@Override @Override
@ -82,7 +82,8 @@ public class Protocol1_17To1_16_4 extends Protocol<ClientboundPackets1_16_2, Cli
protected void onMappingDataLoaded() { protected void onMappingDataLoaded() {
tagRewriter.addEmptyTags(RegistryType.ITEM, "minecraft:candles", "minecraft:ignored_by_piglin_babies", "minecraft:piglin_food", "minecraft:freeze_immune_wearables"); tagRewriter.addEmptyTags(RegistryType.ITEM, "minecraft:candles", "minecraft:ignored_by_piglin_babies", "minecraft:piglin_food", "minecraft:freeze_immune_wearables");
tagRewriter.addEmptyTags(RegistryType.BLOCK, "minecraft:crystal_sound_blocks", "minecraft:candle_cakes", "minecraft:candles", tagRewriter.addEmptyTags(RegistryType.BLOCK, "minecraft:crystal_sound_blocks", "minecraft:candle_cakes", "minecraft:candles",
"minecraft:snow_step_sound_blocks", "minecraft:inside_step_sound_blocks"); "minecraft:snow_step_sound_blocks", "minecraft:inside_step_sound_blocks", "minecraft:occludes_vibration_signals",
"minecraft:dripstone_replaceable_blocks", "minecraft:ignore_vibrations_stepping_carefully");
tagRewriter.addEmptyTag(RegistryType.ENTITY, "minecraft:powder_snow_walkable_mobs"); tagRewriter.addEmptyTag(RegistryType.ENTITY, "minecraft:powder_snow_walkable_mobs");
tagRewriter.addTag(RegistryType.BLOCK, "minecraft:cauldrons", 261); tagRewriter.addTag(RegistryType.BLOCK, "minecraft:cauldrons", 261);
} }

Datei anzeigen

@ -1,5 +1,10 @@
package us.myles.ViaVersion.protocols.protocol1_17to1_16_4.packets; package us.myles.ViaVersion.protocols.protocol1_17to1_16_4.packets;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.entities.Entity1_16_2Types; import us.myles.ViaVersion.api.entities.Entity1_16_2Types;
@ -15,6 +20,10 @@ import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage.BiomeStorage;
import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage.EntityTracker1_17; import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage.EntityTracker1_17;
import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type; import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
public class WorldPackets { public class WorldPackets {
public static void register(Protocol1_17To1_16_4 protocol) { public static void register(Protocol1_17To1_16_4 protocol) {
@ -28,17 +37,45 @@ public class WorldPackets {
protocol.registerOutgoing(ClientboundPackets1_16_2.UPDATE_LIGHT, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_16_2.UPDATE_LIGHT, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // x
map(Type.VAR_INT); // y
map(Type.BOOLEAN); // trust edges
handler(wrapper -> { handler(wrapper -> {
wrapper.passthrough(Type.VAR_INT); int skyLightMask = wrapper.read(Type.VAR_INT);
wrapper.passthrough(Type.VAR_INT); int blockLightMask = wrapper.read(Type.VAR_INT);
wrapper.passthrough(Type.BOOLEAN); // Now all written as a representation of BitSets
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(skyLightMask)); // Sky light mask
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(blockLightMask)); // Block light mask
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(wrapper.read(Type.VAR_INT))); // Empty sky light mask
wrapper.write(Type.LONG_ARRAY_PRIMITIVE, toBitSetLongArray(wrapper.read(Type.VAR_INT))); // Empty block light mask
wrapper.write(Type.VAR_LONG, wrapper.read(Type.VAR_INT).longValue()); // Sky mask writeLightArrays(wrapper, skyLightMask);
wrapper.write(Type.VAR_LONG, wrapper.read(Type.VAR_INT).longValue()); // Block mask writeLightArrays(wrapper, blockLightMask);
wrapper.write(Type.VAR_LONG, wrapper.read(Type.VAR_INT).longValue()); // Empty sky mask
wrapper.write(Type.VAR_LONG, wrapper.read(Type.VAR_INT).longValue()); // Empty block mask
}); });
} }
private void writeLightArrays(PacketWrapper wrapper, int bitMask) throws Exception {
List<byte[]> light = new ArrayList<>();
for (int i = 0; i <= 17; i++) {
if (isSet(bitMask, i)) {
light.add(wrapper.read(Type.BYTE_ARRAY_PRIMITIVE));
}
}
// Now needs the length of the bytearray-array
wrapper.write(Type.VAR_INT, light.size());
for (byte[] bytes : light) {
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, bytes);
}
}
private long[] toBitSetLongArray(int bitmask) {
return new long[]{bitmask};
}
private boolean isSet(int mask, int i) {
return (mask & (1 << i)) != 0;
}
}); });
protocol.registerOutgoing(ClientboundPackets1_16_2.CHUNK_DATA, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_16_2.CHUNK_DATA, new PacketRemapper() {
@ -77,14 +114,28 @@ public class WorldPackets {
protocol.registerOutgoing(ClientboundPackets1_16_2.JOIN_GAME, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_16_2.JOIN_GAME, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); map(Type.INT); // Entity ID
map(Type.BOOLEAN); map(Type.BOOLEAN); // Hardcore
map(Type.UNSIGNED_BYTE); map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); map(Type.STRING_ARRAY); // World List
map(Type.NBT); map(Type.NBT); // Registry
map(Type.NBT); map(Type.NBT); // Current dimension
handler(wrapper -> { handler(wrapper -> {
// Add new dimension fields
CompoundTag dimensionRegistry = wrapper.get(Type.NBT, 0).get("minecraft:dimension_type");
ListTag dimensions = dimensionRegistry.get("value");
for (Tag dimension : dimensions) {
CompoundTag dimensionCompound = ((CompoundTag) dimension).get("element");
dimensionCompound.put(new IntTag("min_y", 0));
dimensionCompound.put(new IntTag("height", 256));
}
CompoundTag currentDimensionTag = wrapper.get(Type.NBT, 1);
currentDimensionTag.put(new IntTag("min_y", 0));
currentDimensionTag.put(new IntTag("height", 256));
// Tracking
String world = wrapper.passthrough(Type.STRING); String world = wrapper.passthrough(Type.STRING);
UserConnection user = wrapper.user(); UserConnection user = wrapper.user();

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.3.0-20w48a</version> <version>3.3.0-20w49a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.3.0-20w48a</version> <version>3.3.0-20w49a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<name>viaversion-jar</name> <name>viaversion-jar</name>

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<version>3.3.0-20w48a</version> <version>3.3.0-20w49a</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>viaversion-parent</name> <name>viaversion-parent</name>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.3.0-20w48a</version> <version>3.3.0-20w49a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.3.0-20w48a</version> <version>3.3.0-20w49a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.3.0-20w48a</version> <version>3.3.0-20w49a</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>