3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-11-17 13:30:14 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2023-10-06 20:56:08 +10:00
Ursprung f923648fe8
Commit 54330702b1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
26 geänderte Dateien mit 381 neuen und 55 gelöschten Zeilen

Datei anzeigen

@ -51,6 +51,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.Protocol1_19_
import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_3To1_19_4;
import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.Protocol1_19_4To1_20;
import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1;
import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3;
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.Protocol1_20To1_20_2;
import com.viaversion.viabackwards.protocol.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2To1_9_3_4;
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
@ -66,7 +67,7 @@ import java.util.logging.Logger;
public interface ViaBackwardsPlatform {
String MINIMUM_VV_VERSION = "4.8.1";
String MINIMUM_VV_VERSION = "4.9.0";
/**
* Initialize ViaBackwards.
@ -133,6 +134,7 @@ public interface ViaBackwardsPlatform {
protocolManager.registerProtocol(new Protocol1_19_4To1_20(), ProtocolVersion.v1_19_4, ProtocolVersion.v1_20);
protocolManager.registerProtocol(new Protocol1_20To1_20_2(), ProtocolVersion.v1_20, ProtocolVersion.v1_20_2);
protocolManager.registerProtocol(new Protocol1_20_2To1_20_3(), ProtocolVersion.v1_20_2, ProtocolVersion.v1_20_3);
}
/**

Datei anzeigen

@ -228,7 +228,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
public void register() {
map(Type.POSITION); // 0 - Position
map(Type.UNSIGNED_BYTE); // 1 - Action
map(Type.NBT); // 2 - NBT
map(Type.NAMED_COMPOUND_TAG); // 2 - NBT
handler(wrapper -> {
// Remove on shulkerbox decleration
@ -237,7 +237,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
}
// Handler Spawners
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 1) {
CompoundTag tag = wrapper.get(Type.NBT, 0);
CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
EntityIdRewriter.toClientSpawner(tag, true);
}
});

Datei anzeigen

@ -193,7 +193,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
public void register() {
map(Type.POSITION); // 0 - Position
map(Type.UNSIGNED_BYTE); // 1 - Action
map(Type.NBT); // 2 - NBT
map(Type.NAMED_COMPOUND_TAG); // 2 - NBT
handler(wrapper -> {
// Remove bed color

Datei anzeigen

@ -147,7 +147,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
public void register() {
map(Type.POSITION); // 0 - Position
map(Type.UNSIGNED_BYTE); // 1 - Action
map(Type.NBT); // 2 - NBT Data
map(Type.NAMED_COMPOUND_TAG); // 2 - NBT Data
handler(wrapper -> {
BackwardsBlockEntityProvider provider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);
@ -157,11 +157,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
wrapper.cancel();
}
wrapper.set(Type.NBT, 0,
wrapper.set(Type.NAMED_COMPOUND_TAG, 0,
provider.transform(
wrapper.user(),
wrapper.get(Type.POSITION, 0),
wrapper.get(Type.NBT, 0)
wrapper.get(Type.NAMED_COMPOUND_TAG, 0)
));
});
}
@ -980,7 +980,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_12_1.BLOCK_ENTITY_DATA, user);
wrapper.write(Type.POSITION, position);
wrapper.write(Type.UNSIGNED_BYTE, (short) 5);
wrapper.write(Type.NBT, nbt);
wrapper.write(Type.NAMED_COMPOUND_TAG, nbt);
wrapper.scheduleSend(Protocol1_12_2To1_13.class);
}

Datei anzeigen

@ -237,7 +237,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
protocol.registerClientbound(ClientboundPackets1_16.BLOCK_ENTITY_DATA, wrapper -> {
wrapper.passthrough(Type.POSITION1_14); // Position
wrapper.passthrough(Type.UNSIGNED_BYTE); // Action
CompoundTag tag = wrapper.passthrough(Type.NBT);
CompoundTag tag = wrapper.passthrough(Type.NAMED_COMPOUND_TAG);
handleBlockEntity(tag);
});

Datei anzeigen

@ -151,7 +151,7 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE, Type.NOTHING); // Previous gamemode
map(Type.STRING_ARRAY, Type.NOTHING); // World list
map(Type.NBT, Type.NOTHING); // whatever this is
map(Type.NAMED_COMPOUND_TAG, Type.NOTHING); // whatever this is
map(dimensionTransformer); // Dimension Type
handler(wrapper -> {
WorldNameTracker worldNameTracker = wrapper.user().get(WorldNameTracker.class);

Datei anzeigen

@ -105,7 +105,7 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
map(Type.POSITION1_14);
map(Type.UNSIGNED_BYTE);
handler(wrapper -> {
handleBlockEntity(wrapper.passthrough(Type.NBT));
handleBlockEntity(wrapper.passthrough(Type.NAMED_COMPOUND_TAG));
});
}
});

Datei anzeigen

@ -72,7 +72,7 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
handler(wrapper -> {
CompoundTag registry = wrapper.read(Type.NBT);
CompoundTag registry = wrapper.read(Type.NAMED_COMPOUND_TAG);
if (wrapper.user().getProtocolInfo().getProtocolVersion() <= ProtocolVersion.v1_15_2.getVersion()) {
// Store biomes for <1.16 client handling
CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
@ -91,9 +91,9 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
}
// Just screw the registry and write the defaults for 1.16 and 1.16.1 clients
wrapper.write(Type.NBT, EntityPackets.DIMENSIONS_TAG);
wrapper.write(Type.NAMED_COMPOUND_TAG, EntityPackets.DIMENSIONS_TAG);
CompoundTag dimensionData = wrapper.read(Type.NBT);
CompoundTag dimensionData = wrapper.read(Type.NAMED_COMPOUND_TAG);
wrapper.write(Type.STRING, getDimensionFromData(dimensionData));
});
map(Type.STRING); // Dimension
@ -108,7 +108,7 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
});
protocol.registerClientbound(ClientboundPackets1_16_2.RESPAWN, wrapper -> {
CompoundTag dimensionData = wrapper.read(Type.NBT);
CompoundTag dimensionData = wrapper.read(Type.NAMED_COMPOUND_TAG);
wrapper.write(Type.STRING, getDimensionFromData(dimensionData));
});
}

Datei anzeigen

@ -71,8 +71,8 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // Worlds
map(Type.NBT); // Dimension registry
map(Type.NBT); // Current dimension data
map(Type.NAMED_COMPOUND_TAG); // Dimension registry
map(Type.NAMED_COMPOUND_TAG); // Current dimension data
map(Type.STRING); // World
handler(wrapper -> {
byte previousGamemode = wrapper.get(Type.BYTE, 0);
@ -83,7 +83,7 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
handler(getTrackerHandler(Entity1_17Types.PLAYER, Type.INT));
handler(worldDataTrackerHandler(1));
handler(wrapper -> {
CompoundTag registry = wrapper.get(Type.NBT, 0);
CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
ListTag biomes = biomeRegistry.get("value");
for (Tag biome : biomes) {
@ -101,7 +101,7 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
reduceExtendedHeight(dimensionCompound, false);
}
reduceExtendedHeight(wrapper.get(Type.NBT, 1), true);
reduceExtendedHeight(wrapper.get(Type.NAMED_COMPOUND_TAG, 1), true);
});
}
});
@ -109,10 +109,10 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
protocol.registerClientbound(ClientboundPackets1_17.RESPAWN, new PacketHandlers() {
@Override
public void register() {
map(Type.NBT); // Dimension data
map(Type.NAMED_COMPOUND_TAG); // Dimension data
map(Type.STRING); // World
handler(worldDataTrackerHandler(0));
handler(wrapper -> reduceExtendedHeight(wrapper.get(Type.NBT, 0), true));
handler(wrapper -> reduceExtendedHeight(wrapper.get(Type.NAMED_COMPOUND_TAG, 0), true));
}
});

Datei anzeigen

@ -131,7 +131,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
map(Type.POSITION1_14);
handler(wrapper -> {
final int id = wrapper.read(Type.VAR_INT);
final CompoundTag tag = wrapper.read(Type.NBT);
final CompoundTag tag = wrapper.read(Type.NAMED_COMPOUND_TAG);
final int mappedId = BlockEntityIds.mappedId(id);
if (mappedId == -1) {
@ -162,7 +162,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
handleSpawner(id, newTag);
wrapper.write(Type.UNSIGNED_BYTE, (short) mappedId);
wrapper.write(Type.NBT, newTag);
wrapper.write(Type.NAMED_COMPOUND_TAG, newTag);
});
}
});

Datei anzeigen

@ -52,8 +52,8 @@ public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // Worlds
map(Type.NBT); // Dimension registry
map(Type.NBT); // Current dimension data
map(Type.NAMED_COMPOUND_TAG); // Dimension registry
map(Type.NAMED_COMPOUND_TAG); // Current dimension data
map(Type.STRING); // World
map(Type.LONG); // Seed
map(Type.VAR_INT); // Max players
@ -61,7 +61,7 @@ public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_
read(Type.VAR_INT); // Read simulation distance
handler(worldDataTrackerHandler(1));
handler(wrapper -> {
final CompoundTag registry = wrapper.get(Type.NBT, 0);
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
final ListTag biomes = biomeRegistry.get("value");
for (final Tag biome : biomes.getValue()) {
@ -85,7 +85,7 @@ public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_
protocol.registerClientbound(ClientboundPackets1_18.RESPAWN, new PacketHandlers() {
@Override
public void register() {
map(Type.NBT); // Dimension data
map(Type.NAMED_COMPOUND_TAG); // Dimension data
map(Type.STRING); // World
handler(worldDataTrackerHandler(0));
}

Datei anzeigen

@ -109,7 +109,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
handler(wrapper -> {
// Remove factor data
if (wrapper.read(Type.BOOLEAN)) {
wrapper.read(Type.NBT);
wrapper.read(Type.NAMED_COMPOUND_TAG);
}
});
}
@ -123,14 +123,14 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // Worlds
map(Type.NBT); // Dimension registry
map(Type.NAMED_COMPOUND_TAG); // Dimension registry
handler(wrapper -> {
final DimensionRegistryStorage dimensionRegistryStorage = wrapper.user().get(DimensionRegistryStorage.class);
dimensionRegistryStorage.clear();
// Cache dimensions and find current dimension
final String dimensionKey = wrapper.read(Type.STRING);
final CompoundTag registry = wrapper.get(Type.NBT, 0);
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final ListTag dimensions = ((CompoundTag) registry.get("minecraft:dimension_type")).get("value");
boolean found = false;
for (final Tag dimension : dimensions) {
@ -140,7 +140,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
dimensionRegistryStorage.addDimension(nameTag.getValue(), dimensionData.clone());
if (!found && nameTag.getValue().equals(dimensionKey)) {
wrapper.write(Type.NBT, dimensionData);
wrapper.write(Type.NAMED_COMPOUND_TAG, dimensionData);
found = true;
}
}
@ -190,7 +190,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
throw new IllegalArgumentException("Could not find dimension " + dimensionKey + " in dimension registry");
}
wrapper.write(Type.NBT, dimension);
wrapper.write(Type.NAMED_COMPOUND_TAG, dimension);
});
map(Type.STRING); // World
map(Type.LONG); // Seed

Datei anzeigen

@ -77,22 +77,22 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol<ClientboundPac
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NBT); // Registry
map(Type.NBT); // Current dimension data
map(Type.NAMED_COMPOUND_TAG); // Registry
map(Type.NAMED_COMPOUND_TAG); // Current dimension data
handler(wrapper -> {
final CompoundTag registry = wrapper.get(Type.NBT, 0);
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final CompoundTag dimensionsHolder = registry.get("minecraft:dimension_type");
final ListTag dimensions = dimensionsHolder.get("value");
for (final Tag dimension : dimensions) {
removeTagPrefix(((CompoundTag) dimension).get("element"));
}
removeTagPrefix(wrapper.get(Type.NBT, 1));
removeTagPrefix(wrapper.get(Type.NAMED_COMPOUND_TAG, 1));
});
}
});
registerClientbound(ClientboundPackets1_18.RESPAWN, wrapper -> removeTagPrefix(wrapper.passthrough(Type.NBT)));
registerClientbound(ClientboundPackets1_18.RESPAWN, wrapper -> removeTagPrefix(wrapper.passthrough(Type.NAMED_COMPOUND_TAG)));
}
private void removeTagPrefix(CompoundTag tag) {

Datei anzeigen

@ -70,7 +70,7 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NBT); // Dimension registry
map(Type.NAMED_COMPOUND_TAG); // Dimension registry
map(Type.STRING); // Dimension key
map(Type.STRING); // World
handler(dimensionDataHandler());
@ -79,7 +79,7 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
handler(wrapper -> {
final ChatTypeStorage1_19_3 chatTypeStorage = wrapper.user().get(ChatTypeStorage1_19_3.class);
chatTypeStorage.clear();
final CompoundTag registry = wrapper.get(Type.NBT, 0);
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final ListTag chatTypes = ((CompoundTag) registry.get("minecraft:chat_type")).get("value");
for (final Tag chatType : chatTypes) {
final CompoundTag chatTypeCompound = (CompoundTag) chatType;

Datei anzeigen

@ -52,14 +52,14 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NBT); // Dimension registry
map(Type.NAMED_COMPOUND_TAG); // Dimension registry
map(Type.STRING); // Dimension key
map(Type.STRING); // World
handler(dimensionDataHandler());
handler(biomeSizeTracker());
handler(worldDataTrackerHandlerByKey());
handler(wrapper -> {
final CompoundTag registry = wrapper.get(Type.NBT, 0);
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
registry.remove("minecraft:trim_pattern");
registry.remove("minecraft:trim_material");
registry.remove("minecraft:damage_type");

Datei anzeigen

@ -61,7 +61,7 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NBT); // Dimension registry
map(Type.NAMED_COMPOUND_TAG); // Dimension registry
map(Type.STRING); // Dimension key
map(Type.STRING); // World
map(Type.LONG); // Seed
@ -79,7 +79,7 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
handler(biomeSizeTracker()); // Tracks the amount of biomes sent for chunk data
handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking
handler(wrapper -> {
final CompoundTag registry = wrapper.get(Type.NBT, 0);
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
ListTag values;
// A 1.20 server can't send this element, and the 1.20 client still works, if the element is missing

Datei anzeigen

@ -96,14 +96,14 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NBT); // Dimension registry
map(Type.NAMED_COMPOUND_TAG); // Dimension registry
map(Type.STRING); // Dimension key
map(Type.STRING); // World
handler(wrapper -> {
final ChatRegistryStorage chatTypeStorage = wrapper.user().get(ChatRegistryStorage1_19_1.class);
chatTypeStorage.clear();
final CompoundTag registry = wrapper.get(Type.NBT, 0);
final CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
final ListTag chatTypes = ((CompoundTag) registry.get("minecraft:chat_type")).get("value");
for (final Tag chatType : chatTypes) {
final CompoundTag chatTypeCompound = (CompoundTag) chatType;

Datei anzeigen

@ -0,0 +1,263 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2023 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter.EntityPacketRewriter1_20_3;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundConfigurationPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundConfigurationPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2;
import java.util.BitSet;
public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol<ClientboundPackets1_20_2, ClientboundPackets1_20_2, ServerboundPackets1_20_2, ServerboundPackets1_20_2> {
private final EntityPacketRewriter1_20_3 entityRewriter = new EntityPacketRewriter1_20_3(this);
public Protocol1_20_2To1_20_3() {
super(ClientboundPackets1_20_2.class, ClientboundPackets1_20_2.class, ServerboundPackets1_20_2.class, ServerboundPackets1_20_2.class);
}
@Override
protected void registerPackets() {
super.registerPackets();
// Components are now (mostly) written as nbt instead of json strings
registerClientbound(ClientboundPackets1_20_2.ADVANCEMENTS, wrapper -> {
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
final int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
for (int i = 0; i < size; i++) {
wrapper.passthrough(Type.STRING); // Identifier
// Parent
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.STRING);
}
// Display data
if (wrapper.passthrough(Type.BOOLEAN)) {
convertComponent(wrapper); // Title
convertComponent(wrapper); // Description
wrapper.passthrough(Type.ITEM1_20_2); // Icon
wrapper.passthrough(Type.VAR_INT); // Frame type
final int flags = wrapper.passthrough(Type.INT);
if ((flags & 1) != 0) {
wrapper.passthrough(Type.STRING); // Background texture
}
wrapper.passthrough(Type.FLOAT); // X
wrapper.passthrough(Type.FLOAT); // Y
}
final int requirements = wrapper.passthrough(Type.VAR_INT);
for (int array = 0; array < requirements; array++) {
wrapper.passthrough(Type.STRING_ARRAY);
}
wrapper.passthrough(Type.BOOLEAN); // Send telemetry
}
});
registerClientbound(ClientboundPackets1_20_2.TAB_COMPLETE, wrapper -> {
wrapper.passthrough(Type.VAR_INT); // Transaction id
wrapper.passthrough(Type.VAR_INT); // Start
wrapper.passthrough(Type.VAR_INT); // Length
final int suggestions = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < suggestions; i++) {
wrapper.passthrough(Type.STRING); // Suggestion
convertOptionalComponent(wrapper); // Tooltip
}
});
registerClientbound(ClientboundPackets1_20_2.MAP_DATA, wrapper -> {
wrapper.passthrough(Type.VAR_INT); // Map id
wrapper.passthrough(Type.BYTE); // Scale
wrapper.passthrough(Type.BOOLEAN); // Locked
if (wrapper.passthrough(Type.BOOLEAN)) {
final int icons = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < icons; i++) {
wrapper.passthrough(Type.BYTE); // Type
wrapper.passthrough(Type.BYTE); // X
wrapper.passthrough(Type.BYTE); // Y
wrapper.passthrough(Type.BYTE); // Rotation
convertOptionalComponent(wrapper); // Display name
}
}
});
registerClientbound(ClientboundPackets1_20_2.PLAYER_CHAT, wrapper -> {
wrapper.passthrough(Type.UUID); // Sender
wrapper.passthrough(Type.VAR_INT); // Index
wrapper.passthrough(Type.OPTIONAL_SIGNATURE_BYTES); // Signature
wrapper.passthrough(Type.STRING); // Plain content
wrapper.passthrough(Type.LONG); // Timestamp
wrapper.passthrough(Type.LONG); // Salt
final int lastSeen = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < lastSeen; i++) {
final int index = wrapper.passthrough(Type.VAR_INT);
if (index == 0) {
wrapper.passthrough(Type.SIGNATURE_BYTES);
}
}
convertOptionalComponent(wrapper); // Unsigned content
final int filterMaskType = wrapper.passthrough(Type.VAR_INT);
if (filterMaskType == 2) {
wrapper.passthrough(Type.LONG_ARRAY_PRIMITIVE); // Mask
}
wrapper.passthrough(Type.VAR_INT); // Chat type
convertComponent(wrapper); // Sender
convertOptionalComponent(wrapper); // Target
});
registerClientbound(ClientboundPackets1_20_2.SCOREBOARD_OBJECTIVE, wrapper -> {
wrapper.passthrough(Type.STRING); // Objective Name
final byte action = wrapper.passthrough(Type.BYTE); // Mode
if (action == 0 || action == 2) {
convertComponent(wrapper); // Display Name
}
});
registerClientbound(ClientboundPackets1_20_2.TEAMS, wrapper -> {
wrapper.passthrough(Type.STRING); // Team Name
final byte action = wrapper.passthrough(Type.BYTE); // Mode
if (action == 0 || action == 2) {
convertComponent(wrapper); // Display Name
wrapper.passthrough(Type.BYTE); // Flags
wrapper.passthrough(Type.STRING); // Name Tag Visibility
wrapper.passthrough(Type.STRING); // Collision rule
wrapper.passthrough(Type.VAR_INT); // Color
convertComponent(wrapper); // Prefix
convertComponent(wrapper); // Suffix
}
});
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.DISCONNECT.getId(), ClientboundConfigurationPackets1_20_2.DISCONNECT.getId(), this::convertComponent);
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.RESOURCE_PACK.getId(), ClientboundConfigurationPackets1_20_2.RESOURCE_PACK.getId(), resourcePackHandler());
registerClientbound(ClientboundPackets1_20_2.DISCONNECT, this::convertComponent);
registerClientbound(ClientboundPackets1_20_2.RESOURCE_PACK, resourcePackHandler());
registerClientbound(ClientboundPackets1_20_2.SERVER_DATA, this::convertComponent);
registerClientbound(ClientboundPackets1_20_2.ACTIONBAR, this::convertComponent);
registerClientbound(ClientboundPackets1_20_2.TITLE_TEXT, this::convertComponent);
registerClientbound(ClientboundPackets1_20_2.TITLE_SUBTITLE, this::convertComponent);
registerClientbound(ClientboundPackets1_20_2.DISGUISED_CHAT, this::convertComponent);
registerClientbound(ClientboundPackets1_20_2.SYSTEM_CHAT, this::convertComponent);
registerClientbound(ClientboundPackets1_20_2.OPEN_WINDOW, new PacketHandlers() {
@Override
public void register() {
map(Type.VAR_INT); // Id
map(Type.VAR_INT); // Window Type
handler(wrapper -> convertComponent(wrapper));
}
});
registerClientbound(ClientboundPackets1_20_2.TAB_LIST, wrapper -> {
convertComponent(wrapper);
convertComponent(wrapper);
});
registerClientbound(ClientboundPackets1_20_2.COMBAT_KILL, new PacketHandlers() {
@Override
public void register() {
map(Type.VAR_INT); // Duration
handler(wrapper -> convertComponent(wrapper));
}
});
registerClientbound(ClientboundPackets1_20_2.PLAYER_INFO_UPDATE, wrapper -> {
final BitSet actions = wrapper.passthrough(Type.PROFILE_ACTIONS_ENUM);
final int entries = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < entries; i++) {
wrapper.passthrough(Type.UUID);
if (actions.get(0)) {
wrapper.passthrough(Type.STRING); // Player Name
final int properties = wrapper.passthrough(Type.VAR_INT);
for (int j = 0; j < properties; j++) {
wrapper.passthrough(Type.STRING); // Name
wrapper.passthrough(Type.STRING); // Value
wrapper.passthrough(Type.OPTIONAL_STRING); // Signature
}
}
if (actions.get(1) && wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.UUID); // Session UUID
wrapper.passthrough(Type.PROFILE_KEY);
}
if (actions.get(2)) {
wrapper.passthrough(Type.VAR_INT); // Gamemode
}
if (actions.get(3)) {
wrapper.passthrough(Type.BOOLEAN); // Listed
}
if (actions.get(4)) {
wrapper.passthrough(Type.VAR_INT); // Latency
}
if (actions.get(5)) {
convertOptionalComponent(wrapper); // Display name
}
}
});
}
private PacketHandler resourcePackHandler() {
return wrapper -> {
wrapper.passthrough(Type.STRING); // Url
wrapper.passthrough(Type.STRING); // Hash
wrapper.passthrough(Type.BOOLEAN); // Required
convertOptionalComponent(wrapper);
};
}
private void convertComponent(final PacketWrapper wrapper) throws Exception {
final Tag tag = wrapper.read(Type.TAG);
wrapper.write(Type.COMPONENT, Protocol1_20_3To1_20_2.tagComponentToJson(tag));
}
private void convertOptionalComponent(final PacketWrapper wrapper) throws Exception {
final Tag tag = wrapper.read(Type.OPTIONAL_TAG);
wrapper.write(Type.OPTIONAL_COMPONENT, Protocol1_20_3To1_20_2.tagComponentToJson(tag));
}
@Override
public void init(final UserConnection connection) {
addEntityTracker(connection, new EntityTrackerBase(connection, Entity1_19_4Types.PLAYER));
}
@Override
protected ServerboundPacketType serverboundFinishConfigurationPacket() {
return ServerboundConfigurationPackets1_20_2.FINISH_CONFIGURATION;
}
@Override
protected ClientboundPacketType clientboundFinishConfigurationPacket() {
return ClientboundConfigurationPackets1_20_2.FINISH_CONFIGURATION;
}
@Override
public EntityPacketRewriter1_20_3 getEntityRewriter() {
return entityRewriter;
}
}

Datei anzeigen

@ -0,0 +1,61 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2023 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.types.version.Types1_20_2;
import com.viaversion.viaversion.api.type.types.version.Types1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2;
public final class EntityPacketRewriter1_20_3 extends EntityRewriter<ClientboundPackets1_20_2, Protocol1_20_2To1_20_3> {
public EntityPacketRewriter1_20_3(final Protocol1_20_2To1_20_3 protocol) {
super(protocol);
}
@Override
public void registerPackets() {
registerSpawnTracker(ClientboundPackets1_20_2.SPAWN_ENTITY);
registerMetadataRewriter(ClientboundPackets1_20_2.ENTITY_METADATA, Types1_20_3.METADATA_LIST, Types1_20_2.METADATA_LIST);
registerRemoveEntities(ClientboundPackets1_20_2.REMOVE_ENTITIES);
}
@Override
protected void registerRewrites() {
filter().handler((event, meta) -> {
final MetaType type = meta.metaType();
if (type == Types1_20_3.META_TYPES.componentType) {
meta.setTypeAndValue(Types1_20_2.META_TYPES.componentType, Protocol1_20_3To1_20_2.tagComponentToJson(meta.value()));
} else if (type == Types1_20_3.META_TYPES.optionalComponentType) {
meta.setTypeAndValue(Types1_20_2.META_TYPES.optionalComponentType, Protocol1_20_3To1_20_2.tagComponentToJson(meta.value()));
} else {
meta.setMetaType(Types1_20_2.META_TYPES.byId(type.typeId()));
}
});
}
@Override
public EntityType typeFromId(final int type) {
return Entity1_19_4Types.getTypeFromId(type);
}
}

Datei anzeigen

@ -117,7 +117,7 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol<ClientboundPac
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.REGISTRY_DATA.getId(), -1, wrapper -> {
wrapper.cancel();
final CompoundTag registry = wrapper.read(Type.NAMELESS_NBT);
final CompoundTag registry = wrapper.read(Type.COMPOUND_TAG);
entityPacketRewriter.trackBiomeSize(wrapper.user(), registry);
entityPacketRewriter.cacheDimensionData(wrapper.user(), registry);
wrapper.user().get(ConfigurationPacketStorage.class).setRegistry(registry);

Datei anzeigen

@ -77,13 +77,13 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
protocol.registerClientbound(ClientboundPackets1_20_2.NBT_QUERY, wrapper -> {
wrapper.passthrough(Type.VAR_INT); // Transaction id
wrapper.write(Type.NBT, wrapper.read(Type.NAMELESS_NBT));
wrapper.write(Type.NAMED_COMPOUND_TAG, wrapper.read(Type.COMPOUND_TAG));
});
protocol.registerClientbound(ClientboundPackets1_20_2.BLOCK_ENTITY_DATA, wrapper -> {
wrapper.passthrough(Type.POSITION1_14); // Position
wrapper.passthrough(Type.VAR_INT); // Type
wrapper.write(Type.NBT, handleBlockEntity(wrapper.read(Type.NAMELESS_NBT)));
wrapper.write(Type.NAMED_COMPOUND_TAG, handleBlockEntity(wrapper.read(Type.COMPOUND_TAG)));
});
protocol.registerClientbound(ClientboundPackets1_20_2.CHUNK_DATA, wrapper -> {

Datei anzeigen

@ -125,7 +125,7 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
wrapper.passthrough(Type.BYTE); // Previous gamemode
wrapper.write(Type.STRING_ARRAY, worlds);
wrapper.write(Type.NBT, configurationPacketStorage.registry());
wrapper.write(Type.NAMED_COMPOUND_TAG, configurationPacketStorage.registry());
wrapper.write(Type.STRING, dimensionType);
wrapper.write(Type.STRING, world);
wrapper.write(Type.LONG, seed);
@ -180,7 +180,7 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
wrapper.passthrough(Type.VAR_INT); // Duration
wrapper.passthrough(Type.BYTE); // Flags
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.write(Type.NBT, wrapper.read(Type.NAMELESS_NBT)); // Factor data
wrapper.write(Type.NAMED_COMPOUND_TAG, wrapper.read(Type.COMPOUND_TAG)); // Factor data
}
});

Datei anzeigen

@ -48,11 +48,11 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol<ClientboundPacket
public void register() {
map(Type.POSITION); //Position
map(Type.UNSIGNED_BYTE); //Type
map(Type.NBT); //NBT
map(Type.NAMED_COMPOUND_TAG); //NBT
handler(wrapper -> {
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 9) {
Position position = wrapper.get(Type.POSITION, 0);
CompoundTag tag = wrapper.get(Type.NBT, 0);
CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
wrapper.clearPacket(); //Clear the packet

Datei anzeigen

@ -79,7 +79,7 @@ public class BlockEntity {
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, null, connection);
wrapper.write(Type.POSITION, pos);
wrapper.write(Type.UNSIGNED_BYTE, id);
wrapper.write(Type.NBT, tag);
wrapper.write(Type.NAMED_COMPOUND_TAG, tag);
wrapper.scheduleSend(Protocol1_9_1_2To1_9_3_4.class, false);
}
}

Datei anzeigen

@ -1,4 +1,4 @@
projectVersion=4.8.1
projectVersion=4.9.0-23w40a-SNAPSHOT
# Smile emoji
mcVersions=1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10

Datei anzeigen

@ -3,7 +3,7 @@ metadata.format.version = "1.1"
[versions]
# ViaVersion
viaver = "4.8.1-SNAPSHOT"
viaver = "4.9.0-23w40a-SNAPSHOT"
# Common provided
netty = "4.0.20.Final"