This commit is contained in:
Nassim Jahnke 2022-02-09 19:12:28 +01:00
parent bd0d238f23
commit ee27cbdd22
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
3 changed files with 40 additions and 2 deletions

View File

@ -79,7 +79,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_17 = register(755, "1.17");
public static final ProtocolVersion v1_17_1 = register(756, "1.17.1");
public static final ProtocolVersion v1_18 = register(757, "1.18/1.18.1", new VersionRange("1.18", 0, 1));
public static final ProtocolVersion v1_18_2 = register(758, 66, "1.18.2");
public static final ProtocolVersion v1_18_2 = register(758, 67, "1.18.2");
public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
public static ProtocolVersion register(int version, String name) {

View File

@ -17,8 +17,14 @@
*/
package com.viaversion.viaversion.protocols.protocol1_18_2to1_18;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.rewriter.TagRewriter;
@ -34,5 +40,37 @@ public final class Protocol1_18_2To1_18 extends AbstractProtocol<ClientboundPack
final TagRewriter tagRewriter = new TagRewriter(this);
tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:fall_damage_resetting");
tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS);
registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Entity ID
map(Type.BOOLEAN); // Hardcore
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
handler(wrapper -> {
final CompoundTag registry = wrapper.get(Type.NBT, 0);
final CompoundTag dimensionsHolder = registry.get("minecraft:dimension_type");
final ListTag dimensions = dimensionsHolder.get("value");
for (final Tag dimension : dimensions) {
addTagPrefix(((CompoundTag) dimension).get("element"));
}
addTagPrefix(wrapper.get(Type.NBT, 1));
});
}
});
}
private void addTagPrefix(CompoundTag tag) {
final Tag infiniburnTag = tag.get("infiniburn");
if (infiniburnTag instanceof StringTag) {
final StringTag infiniburn = (StringTag) infiniburnTag;
infiniburn.setValue("#" + infiniburn.getValue());
}
}
}

View File

@ -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.2.0-22w05a-SNAPSHOT
projectVersion=4.2.0-22w06a-SNAPSHOT
# Gradle properties
org.gradle.daemon=true