mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2026-11-04 08:52:10 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c01425641 | ||
|
|
01d26e7ac5 | ||
|
|
99ea6c32ad | ||
|
|
cf231d92b1 | ||
|
|
f555188428 | ||
|
|
93d6fa2e78 | ||
|
|
162fcafb36 | ||
|
|
3d0a0fe590 | ||
|
|
b06556a84e | ||
|
|
ac8bb104b3 | ||
|
|
4b85ca7691 | ||
|
|
ebd8eb79c1 | ||
|
|
09cffbfb33 | ||
|
|
49a1bffc98 | ||
|
|
da022a0b63 | ||
|
|
3beddaf522 | ||
|
|
70139c6838 |
No files matched your search
+1
-1
@@ -58,7 +58,7 @@ public class BlockChangeRecord1_16_2 implements BlockChangeRecord {
|
||||
|
||||
@Override
|
||||
public short getY(int chunkSectionY) {
|
||||
Preconditions.checkArgument(chunkSectionY >= 0, "Invalid chunkSectionY: " + chunkSectionY);
|
||||
Preconditions.checkArgument(chunkSectionY >= 0, "Invalid chunkSectionY: %s", chunkSectionY);
|
||||
return (short) ((chunkSectionY << 4) + sectionY);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class BitSetType extends Type<BitSet> {
|
||||
public BitSetType(final int length) {
|
||||
super(BitSet.class);
|
||||
this.length = length;
|
||||
this.bytesLength = -Math.floorDiv(-length, 8); // Ceiled quotient
|
||||
this.bytesLength = (int) Math.ceil(length / 8D);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,8 +48,8 @@ public class BitSetType extends Type<BitSet> {
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, BitSet object) {
|
||||
Preconditions.checkArgument(object.length() <= length, "BitSet of length " + object.length() + " larger than max length " + length);
|
||||
Preconditions.checkArgument(object.length() <= length, "BitSet of length %s larger than max length %s", object.length(), length);
|
||||
final byte[] bytes = object.toByteArray();
|
||||
buffer.writeBytes(Arrays.copyOf(bytes, bytesLength));
|
||||
buffer.writeBytes(bytes.length == bytesLength ? bytes : Arrays.copyOf(bytes, bytesLength));
|
||||
}
|
||||
}
|
||||
@@ -49,13 +49,13 @@ public class StringType extends Type<String> {
|
||||
int len = Types.VAR_INT.readPrimitive(buffer);
|
||||
|
||||
Preconditions.checkArgument(len <= maxLength * MAX_CHAR_UTF_8_LENGTH,
|
||||
"Cannot receive string longer than Short.MAX_VALUE * " + MAX_CHAR_UTF_8_LENGTH + " bytes (got %s bytes)", len);
|
||||
"Cannot receive string longer than " + maxLength + " * " + MAX_CHAR_UTF_8_LENGTH + " bytes (got %s bytes)", len);
|
||||
|
||||
String string = buffer.toString(buffer.readerIndex(), len, StandardCharsets.UTF_8);
|
||||
buffer.skipBytes(len);
|
||||
|
||||
Preconditions.checkArgument(string.length() <= maxLength,
|
||||
"Cannot receive string longer than Short.MAX_VALUE characters (got %s bytes)", string.length());
|
||||
"Cannot receive string longer than " + maxLength + " characters (got %s bytes)", string.length());
|
||||
|
||||
return string;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class StringType extends Type<String> {
|
||||
@Override
|
||||
public void write(ByteBuf buffer, String object) {
|
||||
if (object.length() > maxLength) {
|
||||
throw new IllegalArgumentException("Cannot send string longer than Short.MAX_VALUE characters (got " + object.length() + " characters)");
|
||||
throw new IllegalArgumentException("Cannot send string longer than " + maxLength + " characters (got " + object.length() + " characters)");
|
||||
}
|
||||
|
||||
byte[] b = object.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
@@ -30,10 +30,18 @@ public interface Copyable {
|
||||
} else if (object instanceof Copyable copyable) {
|
||||
return (T) copyable.copy();
|
||||
} else if (object.getClass().isArray()) {
|
||||
final Object[] array = (Object[]) object;
|
||||
final Object[] copy = (Object[]) Array.newInstance(array.getClass().getComponentType(), array.length);
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
copy[i] = copy(array[i]);
|
||||
final Class<?> componentType = object.getClass().getComponentType();
|
||||
final int length = Array.getLength(object);
|
||||
final Object copy = Array.newInstance(componentType, length);
|
||||
if (componentType.isPrimitive()) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
Array.set(copy, i, Array.get(object, i));
|
||||
}
|
||||
} else {
|
||||
// See if we need to copy elements, too
|
||||
for (int i = 0; i < length; i++) {
|
||||
Array.set(copy, i, copy(Array.get(object, i)));
|
||||
}
|
||||
}
|
||||
return (T) copy;
|
||||
} else {
|
||||
|
||||
@@ -37,6 +37,16 @@ public final class Key {
|
||||
return identifier.substring(index + 1);
|
||||
}
|
||||
|
||||
public static String namespace(final String identifier) {
|
||||
final int index = identifier.indexOf(':');
|
||||
if (index == -1) {
|
||||
return "minecraft";
|
||||
} else if (index == 0) {
|
||||
return "minecraft";
|
||||
}
|
||||
return identifier.substring(0, index);
|
||||
}
|
||||
|
||||
public static String stripMinecraftNamespace(final String identifier) {
|
||||
if (identifier.startsWith("minecraft:")) {
|
||||
return identifier.substring(MINECRAFT_NAMESPACE_LENGTH);
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.viaversion.viaversion.connection;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.ProtocolInfo;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.platform.ViaPlatform;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
@@ -37,7 +38,14 @@ public final class ConnectionDetails {
|
||||
public static final String APP_CHANNEL = "vv:app_details";
|
||||
|
||||
public static void sendConnectionDetails(final UserConnection connection, final String channel) {
|
||||
final ProtocolVersion nativeVersion = connection.getProtocolInfo().protocolVersion();
|
||||
final ProtocolInfo protocolInfo = connection.getProtocolInfo();
|
||||
final ProtocolVersion nativeVersion = protocolInfo.protocolVersion();
|
||||
final ProtocolVersion serverVersion = protocolInfo.serverProtocolVersion();
|
||||
if (serverVersion.equals(nativeVersion)) {
|
||||
// No need to send details if the native version is the same as the server version
|
||||
return;
|
||||
}
|
||||
|
||||
final String platformName = Via.getPlatform().getPlatformName();
|
||||
final String platformVersion = Via.getPlatform().getPlatformVersion();
|
||||
|
||||
|
||||
@@ -263,8 +263,11 @@ public class PacketWrapperImpl implements PacketWrapper {
|
||||
}
|
||||
|
||||
private InformativeException createInformativeException(final Exception cause, final Type<?> type, final int index) {
|
||||
final ProtocolInfo protocolInfo = this.user().getProtocolInfo();
|
||||
return new InformativeException(cause)
|
||||
.set("Packet Type", this.packetType)
|
||||
.set("Client Protocol", protocolInfo.protocolVersion().getName())
|
||||
.set("Server Protocol", protocolInfo.serverProtocolVersion().getName())
|
||||
.set("Index", index)
|
||||
.set("Type", type.getTypeName())
|
||||
.set("Data", this.packetValues)
|
||||
|
||||
+19
-5
@@ -471,21 +471,35 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
CompoundTag entityTag = tag.getCompoundTag("EntityTag");
|
||||
if (entityTag != null) {
|
||||
entityTag = entityTag.copy();
|
||||
// Additional tooltips of items don't validate the entity id in 1.20.4, add the entity id for these back so
|
||||
// 1.20.5+ parses it correctly (as otherwise not used on the client).
|
||||
if (entityTag.contains("variant")) {
|
||||
entityTag.putString("id", "minecraft:painting");
|
||||
} else if (entityTag.contains("ShowArms")) {
|
||||
entityTag.putString("id", "minecraft:armor_stand");
|
||||
}
|
||||
data.set(StructuredDataKey.ENTITY_DATA, entityTag);
|
||||
|
||||
if (entityTag.contains("id")) {
|
||||
data.set(StructuredDataKey.ENTITY_DATA, entityTag);
|
||||
}
|
||||
}
|
||||
|
||||
final CompoundTag blockEntityTag = tag.getCompoundTag("BlockEntityTag");
|
||||
if (blockEntityTag != null) {
|
||||
final CompoundTag clonedTag = blockEntityTag.copy();
|
||||
// Same as above
|
||||
updateBlockEntityTag(connection, data, clonedTag);
|
||||
CompoundTag spawnData = clonedTag.getCompoundTag("SpawnData");
|
||||
if (spawnData == null) {
|
||||
spawnData = clonedTag.getCompoundTag("spawn_data");
|
||||
}
|
||||
if (spawnData != null) {
|
||||
final CompoundTag entity = spawnData.getCompoundTag("entity");
|
||||
if (entity != null && entity.getString("id") != null) {
|
||||
addBlockEntityId(clonedTag, clonedTag.contains("SpawnData") ? "mob_spawner" : "trial_spawner");
|
||||
}
|
||||
}
|
||||
|
||||
// Not always needed, e.g. shields that had the base color in a block entity tag before
|
||||
if (blockEntityTag.contains("id")) {
|
||||
if (clonedTag.contains("id")) {
|
||||
item.dataContainer().set(StructuredDataKey.BLOCK_ENTITY_DATA, clonedTag);
|
||||
}
|
||||
}
|
||||
@@ -1518,7 +1532,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
}
|
||||
|
||||
data.set(StructuredDataKey.CONTAINER1_20_5, filteredItems);
|
||||
addBlockEntityId(tag, "shulker_box"); // Won't happen to the others and doesn't actually have to be correct otherwise
|
||||
addBlockEntityId(tag, "shulker_box");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-11
@@ -247,7 +247,7 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Js
|
||||
if (!data.isEmpty()) {
|
||||
final CompoundTag components;
|
||||
try {
|
||||
components = toTag(connection, data, false);
|
||||
components = toTag(connection, data);
|
||||
} catch (final Exception e) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
protocol.getLogger().log(Level.WARNING, "Error writing components in show_item!", e);
|
||||
@@ -258,7 +258,7 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Js
|
||||
}
|
||||
}
|
||||
|
||||
public CompoundTag toTag(final UserConnection connection, final Map<StructuredDataKey<?>, StructuredData<?>> data, final boolean empty) {
|
||||
public CompoundTag toTag(final UserConnection connection, final Map<StructuredDataKey<?>, StructuredData<?>> data) {
|
||||
final CompoundTag tag = new CompoundTag();
|
||||
for (final Map.Entry<StructuredDataKey<?>, StructuredData<?>> entry : data.entrySet()) {
|
||||
final StructuredDataKey<?> key = entry.getKey();
|
||||
@@ -273,12 +273,8 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Js
|
||||
|
||||
final StructuredData<?> value = entry.getValue();
|
||||
if (value.isEmpty()) {
|
||||
if (empty) {
|
||||
// Theoretically not needed here, but we'll keep it for consistency
|
||||
tag.put("!" + identifier, new CompoundTag());
|
||||
continue;
|
||||
}
|
||||
throw new IllegalArgumentException("Empty structured data: " + identifier);
|
||||
tag.put("!" + identifier, new CompoundTag());
|
||||
continue;
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
@@ -303,11 +299,19 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Js
|
||||
return list;
|
||||
}
|
||||
|
||||
public StructuredData<?> readFromTag(final UserConnection connection, final String identifier, final Tag tag) {
|
||||
private StructuredData<?> readFromTag(final UserConnection connection, String identifier, final Tag tag) {
|
||||
final boolean removed = identifier.startsWith("!");
|
||||
if (removed) {
|
||||
identifier = identifier.substring(1);
|
||||
}
|
||||
final int id = protocol.getMappingData().getDataComponentSerializerMappings().mappedId(identifier);
|
||||
Preconditions.checkArgument(id != -1, "Unknown data component: %s", identifier);
|
||||
final StructuredDataKey<?> key = structuredDataType.key(id);
|
||||
return readFromTag(connection, key, id, tag);
|
||||
if (removed) {
|
||||
return StructuredData.empty(key, id);
|
||||
} else {
|
||||
return readFromTag(connection, key, id, tag);
|
||||
}
|
||||
}
|
||||
|
||||
protected <T> StructuredData<T> readFromTag(final UserConnection connection, final StructuredDataKey<T> key, final int id, final Tag tag) {
|
||||
@@ -1561,7 +1565,7 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Js
|
||||
tag.putInt("count", 1);
|
||||
}
|
||||
final Map<StructuredDataKey<?>, StructuredData<?>> components = item.dataContainer().data();
|
||||
final CompoundTag componentsTag = toTag(connection, components, true);
|
||||
final CompoundTag componentsTag = toTag(connection, components);
|
||||
if (!componentsTag.isEmpty()) {
|
||||
tag.put("components", componentsTag);
|
||||
}
|
||||
|
||||
+49
-2
@@ -54,6 +54,7 @@ import com.viaversion.viaversion.api.minecraft.item.data.TooltipDisplay;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.Unbreakable;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkBiomesType1_19_4;
|
||||
@@ -71,6 +72,7 @@ import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacke
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.rewriter.RecipeDisplayRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import com.viaversion.viaversion.util.Limit;
|
||||
import com.viaversion.viaversion.util.Unit;
|
||||
import it.unimi.dsi.fastutil.ints.IntLinkedOpenHashSet;
|
||||
@@ -206,8 +208,41 @@ public final class BlockItemPacketRewriter1_21_5 extends StructuredItemRewriter<
|
||||
wrapper.write(Types1_21_5.ITEM, handleItemToServer(wrapper.user(), this.convertHashedItemToStructuredItem(wrapper.user(), carriedItem)));
|
||||
});
|
||||
|
||||
registerAdvancements1_20_3(ClientboundPackets1_21_2.UPDATE_ADVANCEMENTS);
|
||||
protocol.appendClientbound(ClientboundPackets1_21_2.UPDATE_ADVANCEMENTS, wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_21_2.UPDATE_ADVANCEMENTS, wrapper -> {
|
||||
wrapper.passthrough(Types.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Types.VAR_INT); // Mapping size
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Types.STRING); // Identifier
|
||||
wrapper.passthrough(Types.OPTIONAL_STRING); // Parent
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Types.BOOLEAN)) {
|
||||
final Tag title = wrapper.passthrough(Types.TAG);
|
||||
final Tag description = wrapper.passthrough(Types.TAG);
|
||||
final ComponentRewriter componentRewriter = protocol.getComponentRewriter();
|
||||
if (componentRewriter != null) {
|
||||
componentRewriter.processTag(wrapper.user(), title);
|
||||
componentRewriter.processTag(wrapper.user(), description);
|
||||
}
|
||||
|
||||
passthroughClientboundItem(wrapper); // Icon
|
||||
wrapper.passthrough(Types.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Types.INT); // Flags
|
||||
if ((flags & 1) != 0) {
|
||||
convertClientAsset(wrapper);
|
||||
}
|
||||
wrapper.passthrough(Types.FLOAT); // X
|
||||
wrapper.passthrough(Types.FLOAT); // Y
|
||||
}
|
||||
|
||||
int requirements = wrapper.passthrough(Types.VAR_INT);
|
||||
for (int array = 0; array < requirements; array++) {
|
||||
wrapper.passthrough(Types.STRING_ARRAY);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Types.BOOLEAN); // Send telemetry
|
||||
}
|
||||
|
||||
wrapper.passthrough(Types.STRING_ARRAY); // Removed
|
||||
final int progressSize = wrapper.passthrough(Types.VAR_INT);
|
||||
for (int i = 0; i < progressSize; i++) {
|
||||
@@ -244,6 +279,18 @@ public final class BlockItemPacketRewriter1_21_5 extends StructuredItemRewriter<
|
||||
recipeRewriter.registerPlaceGhostRecipe(ClientboundPackets1_21_2.PLACE_GHOST_RECIPE);
|
||||
}
|
||||
|
||||
private void convertClientAsset(final PacketWrapper wrapper) {
|
||||
final String background = wrapper.read(Types.STRING);
|
||||
final String namespace = Key.namespace(background);
|
||||
final String path = Key.stripNamespace(background);
|
||||
if (path.startsWith("textures/") && path.endsWith(".png")) {
|
||||
final String stripped = path.substring("textures/".length(), path.length() - ".png".length());
|
||||
wrapper.write(Types.STRING, namespace + ":" + stripped);
|
||||
} else {
|
||||
wrapper.write(Types.STRING, namespace + ":" + path);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleBlockEntity(final UserConnection connection, final BlockEntity blockEntity) {
|
||||
final CompoundTag tag = blockEntity.tag();
|
||||
if (tag != null && (blockEntity.typeId() == SIGN_BOCK_ENTITY_ID || blockEntity.typeId() == HANGING_SIGN_BOCK_ENTITY_ID)) {
|
||||
|
||||
+18
-17
@@ -109,6 +109,19 @@ public final class ComponentRewriter1_21_5 extends JsonNBTComponentRewriter<Clie
|
||||
handleEnchantments(componentsTag, "enchantments");
|
||||
handleEnchantments(componentsTag, "stored_enchantments");
|
||||
|
||||
// Usual item handling
|
||||
final CompoundTag useRemainder = TagUtil.getNamespacedCompoundTag(componentsTag, "use_remainder");
|
||||
if (useRemainder != null) {
|
||||
handleShowItem(connection, useRemainder);
|
||||
}
|
||||
handleContainerContents(connection, componentsTag);
|
||||
handleItemArrayContents(connection, componentsTag, "bundle_contents");
|
||||
handleItemArrayContents(connection, componentsTag, "charged_projectiles");
|
||||
handleWrittenBookContents(connection, componentsTag);
|
||||
|
||||
// NO MORE SNBT IN TEXT COMPONENTS
|
||||
updateUglyJson(componentsTag, connection);
|
||||
|
||||
removeDataComponents(componentsTag, StructuredDataKey.INSTRUMENT1_21_2, StructuredDataKey.JUKEBOX_PLAYABLE1_21);
|
||||
}
|
||||
|
||||
@@ -218,22 +231,9 @@ public final class ComponentRewriter1_21_5 extends JsonNBTComponentRewriter<Clie
|
||||
final CompoundTag componentsTag = compoundContents.getCompoundTag("components");
|
||||
handleShowItem(connection, compoundContents, componentsTag);
|
||||
|
||||
if (componentsTag == null) {
|
||||
return;
|
||||
if (componentsTag != null) {
|
||||
hoverEventTag.put("components", componentsTag);
|
||||
}
|
||||
|
||||
hoverEventTag.put("components", componentsTag);
|
||||
|
||||
final CompoundTag useRemainder = TagUtil.getNamespacedCompoundTag(componentsTag, "use_remainder");
|
||||
if (useRemainder != null) {
|
||||
handleShowItem(connection, useRemainder);
|
||||
}
|
||||
handleContainerContents(connection, componentsTag);
|
||||
handleItemArrayContents(connection, componentsTag, "bundle_contents");
|
||||
handleItemArrayContents(connection, componentsTag, "charged_projectiles");
|
||||
handleWrittenBookContents(connection, componentsTag);
|
||||
|
||||
updateUglyJson(componentsTag, connection);
|
||||
} else if (contentsTag instanceof final StringTag inlinedContents) {
|
||||
hoverEventTag.put("id", inlinedContents);
|
||||
}
|
||||
@@ -267,7 +267,7 @@ public final class ComponentRewriter1_21_5 extends JsonNBTComponentRewriter<Clie
|
||||
final String actualKey = TagUtil.getNamespacedTagKey(componentsTag, key);
|
||||
final String json = componentsTag.getString(actualKey);
|
||||
if (json == null) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
componentsTag.put(actualKey, uglyJsonToTag(connection, json));
|
||||
@@ -299,7 +299,8 @@ public final class ComponentRewriter1_21_5 extends JsonNBTComponentRewriter<Clie
|
||||
}
|
||||
|
||||
public Tag uglyJsonToTag(final UserConnection connection, final String value) {
|
||||
final Tag contents = SerializerVersion.V1_21_5.toTag(SerializerVersion.V1_21_4.toComponent(value));
|
||||
// Use the same version for deserializing and serializing, as we handle the remaining changes ourselves
|
||||
final Tag contents = SerializerVersion.V1_21_4.toTag(SerializerVersion.V1_21_4.toComponent(value));
|
||||
processTag(connection, contents);
|
||||
return contents;
|
||||
}
|
||||
|
||||
+22
-6
@@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21;
|
||||
@@ -265,20 +266,21 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter<Clientbound
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_21_2.PLAYER_INPUT, wrapper -> {
|
||||
// Previously only used while in a vehicle, now always sent
|
||||
// Filter them appropriately
|
||||
if (!wrapper.user().has(ClientVehicleStorage.class)) {
|
||||
wrapper.cancel();
|
||||
// Filter them appropriately and always send them when in a vehicle
|
||||
wrapper.cancel();
|
||||
final ClientVehicleStorage vehicleStorage = wrapper.user().get(ClientVehicleStorage.class);
|
||||
if (vehicleStorage == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final byte flags = wrapper.read(Types.BYTE);
|
||||
final boolean left = (flags & 1 << 2) != 0;
|
||||
final boolean right = (flags & 1 << 3) != 0;
|
||||
wrapper.write(Types.FLOAT, left ? IMPULSE : (right ? -IMPULSE : 0F));
|
||||
final float sidewaysMovement = left ? IMPULSE : (right ? -IMPULSE : 0F);
|
||||
|
||||
final boolean forward = (flags & 1 << 0) != 0;
|
||||
final boolean backward = (flags & 1 << 1) != 0;
|
||||
wrapper.write(Types.FLOAT, forward ? IMPULSE : (backward ? -IMPULSE : 0F));
|
||||
final float forwardMovement = forward ? IMPULSE : (backward ? -IMPULSE : 0F);
|
||||
|
||||
byte updatedFlags = 0;
|
||||
if ((flags & 1 << 4) != 0) {
|
||||
@@ -287,7 +289,8 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter<Clientbound
|
||||
if ((flags & 1 << 5) != 0) {
|
||||
updatedFlags |= 2;
|
||||
}
|
||||
wrapper.write(Types.BYTE, updatedFlags);
|
||||
|
||||
vehicleStorage.storeMovement(sidewaysMovement, forwardMovement, updatedFlags);
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_21.TELEPORT_ENTITY, ClientboundPackets1_21_2.ENTITY_POSITION_SYNC, wrapper -> {
|
||||
@@ -346,6 +349,19 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter<Clientbound
|
||||
wrapper.passthrough(Types.FLOAT); // Yaw
|
||||
wrapper.passthrough(Types.FLOAT); // Pitch
|
||||
handleOnGround(wrapper);
|
||||
|
||||
final ClientVehicleStorage vehicleStorage = wrapper.user().get(ClientVehicleStorage.class);
|
||||
if (vehicleStorage == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.sendToServer(Protocol1_21To1_21_2.class);
|
||||
wrapper.cancel();
|
||||
final PacketWrapper playerInput = wrapper.create(ServerboundPackets1_20_5.PLAYER_INPUT);
|
||||
playerInput.write(Types.FLOAT, vehicleStorage.sidewaysMovement());
|
||||
playerInput.write(Types.FLOAT, vehicleStorage.forwardMovement());
|
||||
playerInput.write(Types.BYTE, vehicleStorage.flags());
|
||||
playerInput.sendToServer(Protocol1_21To1_21_2.class);
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_21_2.MOVE_PLAYER_STATUS_ONLY, wrapper -> {
|
||||
final GroundFlagTracker tracker = wrapper.user().get(GroundFlagTracker.class);
|
||||
|
||||
+34
-1
@@ -19,5 +19,38 @@ package com.viaversion.viaversion.protocols.v1_21to1_21_2.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public record ClientVehicleStorage(int vehicleId) implements StorableObject {
|
||||
public final class ClientVehicleStorage implements StorableObject {
|
||||
|
||||
private final int vehicleId;
|
||||
|
||||
private float sidewaysMovement;
|
||||
private float forwardMovement;
|
||||
private byte flags;
|
||||
|
||||
public ClientVehicleStorage(final int vehicleId) {
|
||||
this.vehicleId = vehicleId;
|
||||
}
|
||||
|
||||
public void storeMovement(final float sidewaysMovement, final float forwardMovement, final byte flags) {
|
||||
this.sidewaysMovement = sidewaysMovement;
|
||||
this.forwardMovement = forwardMovement;
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
public int vehicleId() {
|
||||
return vehicleId;
|
||||
}
|
||||
|
||||
public float sidewaysMovement() {
|
||||
return sidewaysMovement;
|
||||
}
|
||||
|
||||
public float forwardMovement() {
|
||||
return forwardMovement;
|
||||
}
|
||||
|
||||
public byte flags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -255,12 +255,12 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
||||
wrapper.passthrough(Types.SHORT); // Slot
|
||||
wrapper.passthrough(Types.BYTE); // Button
|
||||
wrapper.passthrough(Types.VAR_INT); // Mode
|
||||
passthroughHashedItem(wrapper); // Carried item
|
||||
final int affectedItems = Limit.max(wrapper.passthrough(Types.VAR_INT), 128);
|
||||
for (int i = 0; i < affectedItems; i++) {
|
||||
wrapper.passthrough(Types.SHORT); // Slot
|
||||
passthroughHashedItem(wrapper);
|
||||
}
|
||||
passthroughHashedItem(wrapper); // Carried item
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public final class ComponentUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static Tag trimStrings(final Tag input) {
|
||||
public static Tag trimStrings(final Tag input) {
|
||||
// Dirty fix for https://github.com/ViaVersion/ViaVersion/issues/3650
|
||||
// Usually tripped by hover event data being too long, e.g. book or shulker box contents, which have to be held in full as SNBT
|
||||
if (input == null) {
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
|
||||
projectVersion=5.3.1
|
||||
projectVersion=5.3.2
|
||||
|
||||
# Smile emoji
|
||||
mcVersions=1.21.5,1.21.4, 1.21.3, 1.21.2, 1.21.1, 1.21, 1.20.6, 1.20.5, 1.20.4, 1.20.3, 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, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9
|
||||
mcVersions=1.21.5, 1.21.4, 1.21.3, 1.21.2, 1.21.1, 1.21, 1.20.6, 1.20.5, 1.20.4, 1.20.3, 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, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9
|
||||
mcVersionRange=1.8-1.21.5
|
||||
velocityVersion=3.4
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ metadata.format.version = "1.1"
|
||||
gson = "2.12.1"
|
||||
fastutil = "8.5.15"
|
||||
vianbt = "5.1.0"
|
||||
mcstructs = "5-3.0.0"
|
||||
mcstructs = "5-3.1.0-SNAPSHOT"
|
||||
|
||||
# Common provided
|
||||
netty = "4.0.20.Final"
|
||||
@@ -19,7 +19,7 @@ checkerQual = "3.49.1"
|
||||
paper = "1.20.4-R0.1-SNAPSHOT"
|
||||
legacyBukkit = "1.8.8-R0.1-SNAPSHOT"
|
||||
velocity = "3.1.1"
|
||||
viaProxy = "3.4.1-SNAPSHOT"
|
||||
viaProxy = "3.4.2-SNAPSHOT"
|
||||
|
||||
[libraries]
|
||||
|
||||
|
||||
+4
-2
@@ -32,8 +32,10 @@ public class ConnectionDetailsListener {
|
||||
|
||||
@Subscribe
|
||||
public void onPostServerJoin(final ServerPostConnectEvent event) {
|
||||
final UserConnection connection = Via.getAPI().getConnection(event.getPlayer().getUniqueId());
|
||||
ConnectionDetails.sendConnectionDetails(connection, ConnectionDetails.PROXY_CHANNEL);
|
||||
final UserConnection connection = Via.getManager().getConnectionManager().getClientConnection(event.getPlayer().getUniqueId());
|
||||
if (connection != null) {
|
||||
ConnectionDetails.sendConnectionDetails(connection, ConnectionDetails.PROXY_CHANNEL);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
Reference in new issue
Block a user