From a2c1c52f518e484e883abe32aee2bbd643a968cf Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 27 Mar 2024 20:48:12 +0100 Subject: [PATCH] 24w13a --- .../api/minecraft/data/StructuredDataKey.java | 2 + .../minecraft/entities/EntityTypes1_20_5.java | 1 + .../api/protocol/version/ProtocolVersion.java | 2 +- .../viaversion/viaversion/api/type/Type.java | 1 + .../Protocol1_19_3To1_19_1.java | 5 +- .../Protocol1_20_5To1_20_3.java | 23 +++++++- .../data/MappingData.java | 2 +- ...ClientboundConfigurationPackets1_20_5.java | 17 +++--- .../packet/ServerboundPackets1_20_5.java | 1 + .../rewriter/EntityPacketRewriter1_20_5.java | 12 +++++ .../rewriter/StructuredDataConverter.java | 7 +++ .../storage/AcknowledgedMessagesStorage.java | 51 ++++++++++++++++++ .../viaversion/data/identifiers-1.20.3.nbt | Bin 4801 -> 4838 bytes .../viaversion/data/identifiers-1.20.5.nbt | Bin 4905 -> 5086 bytes .../data/mappings-1.20.3to1.20.5.nbt | Bin 771 -> 945 bytes gradle.properties | 2 +- 16 files changed, 111 insertions(+), 15 deletions(-) create mode 100644 common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/storage/AcknowledgedMessagesStorage.java diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataKey.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataKey.java index 357aa0f02..5b0fade61 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataKey.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataKey.java @@ -59,6 +59,7 @@ public final class StructuredDataKey { public static final StructuredDataKey DAMAGE = new StructuredDataKey<>("damage", Type.VAR_INT); public static final StructuredDataKey UNBREAKABLE = new StructuredDataKey<>("unbreakable", Unbreakable.TYPE); public static final StructuredDataKey CUSTOM_NAME = new StructuredDataKey<>("custom_name", Type.TAG); + public static final StructuredDataKey ITEM_NAME = new StructuredDataKey<>("item_name", Type.TAG); public static final StructuredDataKey LORE = new StructuredDataKey<>("lore", Type.TAG_ARRAY); public static final StructuredDataKey RARITY = new StructuredDataKey<>("rarity", Type.VAR_INT); public static final StructuredDataKey ENCHANTMENTS = new StructuredDataKey<>("enchantments", Enchantments.TYPE); @@ -93,6 +94,7 @@ public final class StructuredDataKey { public static final StructuredDataKey BUCKET_ENTITY_DATA = new StructuredDataKey<>("bucket_entity_data", Type.COMPOUND_TAG); public static final StructuredDataKey BLOCK_ENTITY_DATA = new StructuredDataKey<>("block_entity_data", Type.COMPOUND_TAG); public static final StructuredDataKey> INSTRUMENT = new StructuredDataKey<>("instrument", Instrument.TYPE); + public static final StructuredDataKey OMINOUS_BOTTLE_AMPLIFIER = new StructuredDataKey<>("ominous_bottle_amplifier", Type.VAR_INT); public static final StructuredDataKey RECIPES = new StructuredDataKey<>("recipes", Type.TAG); public static final StructuredDataKey LODESTONE_TRACKER = new StructuredDataKey<>("lodestone_tracker", LodestoneTracker.TYPE); public static final StructuredDataKey FIREWORK_EXPLOSION = new StructuredDataKey<>("firework_explosion", FireworkExplosion.TYPE); diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java index 909810611..ad03ee8a4 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityTypes1_20_5.java @@ -44,6 +44,7 @@ public enum EntityTypes1_20_5 implements EntityType { TNT(ENTITY), SHULKER_BULLET(ENTITY), FISHING_BOBBER(ENTITY), + OMINOUS_ITEM_SPAWNER(ENTITY), LIVINGENTITY(ENTITY, null), ARMOR_STAND(LIVINGENTITY), diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java index 5f38ffe73..a769ba123 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java @@ -83,7 +83,7 @@ public class ProtocolVersion implements Comparable { public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new SubVersionRange("1.20", 0, 1)); public static final ProtocolVersion v1_20_2 = register(764, "1.20.2"); public static final ProtocolVersion v1_20_3 = register(765, "1.20.3/1.20.4", new SubVersionRange("1.20", 3, 4)); - public static final ProtocolVersion v1_20_5 = register(766, 181, "1.20.5"); + public static final ProtocolVersion v1_20_5 = register(766, 182, "1.20.5"); public static final ProtocolVersion unknown = new ProtocolVersion(VersionType.SPECIAL, -1, -1, "UNKNOWN", null); public static ProtocolVersion register(int version, String name) { diff --git a/api/src/main/java/com/viaversion/viaversion/api/type/Type.java b/api/src/main/java/com/viaversion/viaversion/api/type/Type.java index 7cb49cb00..1c652921c 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/type/Type.java +++ b/api/src/main/java/com/viaversion/viaversion/api/type/Type.java @@ -194,6 +194,7 @@ public abstract class Type implements ByteBufReader, ByteBufWriter { public static final BitSetType PROFILE_ACTIONS_ENUM = new BitSetType(6); public static final ByteArrayType SIGNATURE_BYTES = new ByteArrayType(256); + public static final BitSetType ACKNOWLEDGED_BIT_SET = new BitSetType(20); public static final ByteArrayType.OptionalByteArrayType OPTIONAL_SIGNATURE_BYTES = new ByteArrayType.OptionalByteArrayType(256); public static final Type REGISTRY_ENTRY = new RegistryEntryType(); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java index a5a054187..352f5e055 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19_3to1_19_1/Protocol1_19_3To1_19_1.java @@ -62,7 +62,6 @@ import java.util.concurrent.ThreadLocalRandom; public final class Protocol1_19_3To1_19_1 extends AbstractProtocol { public static final MappingData MAPPINGS = new MappingDataBase("1.19", "1.19.3"); - private static final BitSetType ACKNOWLEDGED_BIT_SET_TYPE = new BitSetType(20); private static final UUID ZERO_UUID = new UUID(0, 0); private static final byte[] EMPTY_BYTES = new byte[0]; private final EntityPackets entityRewriter = new EntityPackets(this); @@ -247,7 +246,7 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol wrapper.user().get(AcknowledgedMessagesStorage.class).add()); + registerServerbound(ServerboundPackets1_20_5.CHAT_MESSAGE, wrapper -> wrapper.user().get(AcknowledgedMessagesStorage.class).clearOffset()); + registerServerbound(ServerboundPackets1_20_5.CHAT_ACK, wrapper -> wrapper.user().get(AcknowledgedMessagesStorage.class).clearOffset()); + registerServerbound(ServerboundPackets1_20_5.CHAT_COMMAND_SIGNED, ServerboundPackets1_20_3.CHAT_COMMAND); + registerServerbound(ServerboundPackets1_20_5.CHAT_COMMAND, wrapper -> { + wrapper.passthrough(Type.STRING); // Command + + final AcknowledgedMessagesStorage messagesStorage = wrapper.user().get(AcknowledgedMessagesStorage.class); + wrapper.write(Type.LONG, System.currentTimeMillis()); // Timestamp + wrapper.write(Type.LONG, 0L); // Salt + wrapper.write(Type.VAR_INT, 0); // No signatures + wrapper.write(Type.VAR_INT, messagesStorage.offset()); // TODO Fix offset + wrapper.write(Type.ACKNOWLEDGED_BIT_SET, messagesStorage.toAck()); + messagesStorage.clearOffset(); + }); + registerClientbound(ClientboundPackets1_20_3.START_CONFIGURATION, wrapper -> wrapper.user().put(new AcknowledgedMessagesStorage())); + new CommandRewriter1_19_4<>(this).registerDeclareCommands1_19(ClientboundPackets1_20_3.DECLARE_COMMANDS); cancelServerbound(State.LOGIN, ServerboundLoginPackets.COOKIE_RESPONSE.getId()); @@ -108,6 +126,7 @@ public final class Protocol1_20_5To1_20_3 extends AbstractProtocol dimensionTypes = registryData.getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class); + for (final CompoundTag dimensionType : dimensionTypes) { + final CompoundTag elementTag = dimensionType.getCompoundTag("element"); + final CompoundTag monsterSpawnLightLevel = elementTag.getCompoundTag("monster_spawn_light_level"); + if (monsterSpawnLightLevel != null) { + final CompoundTag value = monsterSpawnLightLevel.removeUnchecked("value"); + monsterSpawnLightLevel.putInt("min_inclusive", value.getInt("min_inclusive")); + monsterSpawnLightLevel.putInt("max_inclusive", value.getInt("max_inclusive")); + } + } + for (final Map.Entry entry : registryData.entrySet()) { final CompoundTag entryTag = (CompoundTag) entry.getValue(); final String type = entryTag.getString("type"); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/StructuredDataConverter.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/StructuredDataConverter.java index a5b2bc67e..e7879d11e 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/StructuredDataConverter.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/rewriter/StructuredDataConverter.java @@ -85,6 +85,12 @@ final class StructuredDataConverter { } }); register(StructuredDataKey.CUSTOM_NAME, (data, tag) -> getDisplayTag(tag).putString("Name", ComponentUtil.tagToJsonString(data))); + register(StructuredDataKey.ITEM_NAME, (data, tag) -> { + final CompoundTag displayTag = tag.getCompoundTag("display"); + if (displayTag != null && !displayTag.contains("Name")) { + displayTag.putString("Name", ComponentUtil.tagToJsonString(data)); + } + }); register(StructuredDataKey.LORE, (data, tag) -> { final ListTag lore = new ListTag<>(StringTag.class); for (final Tag loreEntry : data) { @@ -448,6 +454,7 @@ final class StructuredDataConverter { noop(StructuredDataKey.FOOD); noop(StructuredDataKey.FIRE_RESISTANT); noop(StructuredDataKey.TOOL); + noop(StructuredDataKey.OMINOUS_BOTTLE_AMPLIFIER); } private static String toItemName(final int id) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/storage/AcknowledgedMessagesStorage.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/storage/AcknowledgedMessagesStorage.java new file mode 100644 index 000000000..6f81c91dc --- /dev/null +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20_5to1_20_3/storage/AcknowledgedMessagesStorage.java @@ -0,0 +1,51 @@ +/* + * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion + * Copyright (C) 2016-2024 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 . + */ +package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.storage; + +import com.viaversion.viaversion.api.connection.StorableObject; +import java.util.BitSet; + +public final class AcknowledgedMessagesStorage implements StorableObject { + private static final int MAX_HISTORY = 20; + private final boolean[] trackedMessages = new boolean[MAX_HISTORY]; + private int offset; + private int tail; + + public void add() { + this.offset++; + this.trackedMessages[this.tail] = true; + this.tail = (this.tail + 1) % MAX_HISTORY; + } + + public BitSet toAck() { + final BitSet acks = new BitSet(MAX_HISTORY); + for (int i = 0; i < MAX_HISTORY; i++) { + final int messageIndex = (this.tail + i) % MAX_HISTORY; + acks.set(i, this.trackedMessages[messageIndex]); + } + return acks; + } + + public int offset() { + return this.offset; + } + + public void clearOffset() { + this.offset = 0; + } +} diff --git a/common/src/main/resources/assets/viaversion/data/identifiers-1.20.3.nbt b/common/src/main/resources/assets/viaversion/data/identifiers-1.20.3.nbt index 2751e44b9efba44bec6daeab53a17737005302c6..2d65b5b2b1e293795599c616f394870aafc9c998 100644 GIT binary patch delta 53 zcmX@8`b>4h41Pw7$us$VSU59FQa9h@*JhHG$j{Bp%P%dCPs%ST$w`e*%q_^tOv_9y Jn#>`z695kg6UP7m delta 22 ecmaE+dQf%441Pwl$us$VHhT~bgWQLzFl_AnaTFVU0cW6eC1o-LS`1*Ae~DjG^k zmO#ZKC}SmYccrUy@7XSXm$L#OhYT$f6NU@`UOr}T;$rR$S=R+gj7El5Z7lluF8)Mf z;_KutNsC~V*0TRPRe45sg@Li@uhZ?>bkEeT+F%vG(|@tPVNXhrGqOR(n#oyte1Y;= zb(&@EtUWX^ZMwj+C9Rc*a_?qqbrWBCADeRR3OdTdJqd61nYgaKrzHt`fzC%Lk!Iyc~$c zXS_&@+;tqCgzxZEYTSg|@D~0^aUCK^d@)OUK=3K}0lx@bg}d;Hz!*BP0LL)ZtcH^^ z3tctW0$0t*yE;OF6~KjF!yEWW$4l^1v<%PSIlO@1n79VtV4tGf@EN|qo_B4cxYRxP z0AFDj!8`CCkyr2z>^Jw(B4j{^4eJOKG2@9T)@;*NJ1=`%Y3T-e>B8Q0G3ZSfd~d8x z=e;L8ETJ`vM&XL7_3LS<^Tg{kNM$o5OSX{fUehjEm)g*QTZGJw(y=Rg{pkXOut4q$ z%#v%5c{~m$;51x<9%R0t1$Mz63*=kUS-1>q@DKy@>3DNulX8zn(7RT(OhnQxNd*oQ->QS`>2B%#+*Fq?7$6+Ey|;_Ly@es7)zl|I6I) OkX*UpC8hRPuKxfQd@t(& diff --git a/gradle.properties b/gradle.properties index 57a5a9ce5..756ebc4b7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project properties - we put these here so they can be modified without causing a recompile of the build scripts -projectVersion=4.10.0-24w12a-SNAPSHOT +projectVersion=4.10.0-24w13a-SNAPSHOT # Smile emoji mcVersions=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