Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-19 14:30:16 +01:00
Fix various issues
Dieser Commit ist enthalten in:
Ursprung
4255876c22
Commit
c2567115d8
@ -130,4 +130,11 @@ public final class StructuredDataContainer {
|
|||||||
public Map<StructuredDataKey<?>, StructuredData<?>> data() {
|
public Map<StructuredDataKey<?>, StructuredData<?>> data() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "StructuredDataContainer{" +
|
||||||
|
"data=" + data +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,4 +114,12 @@ public final class StructuredDataKey<T> {
|
|||||||
public String identifier() {
|
public String identifier() {
|
||||||
return identifier;
|
return identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "StructuredDataKey{" +
|
||||||
|
"identifier='" + identifier + '\'' +
|
||||||
|
", type=" + type +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ public abstract class Filterable<T> {
|
|||||||
private final Type<T> elementType;
|
private final Type<T> elementType;
|
||||||
private final Type<T> optionalElementType;
|
private final Type<T> optionalElementType;
|
||||||
|
|
||||||
protected FilterableType(final Type<T> elementType, final Type<T> optionalElementType) {
|
protected FilterableType(final Type<T> elementType, final Type<T> optionalElementType, final Class<F> outputClass) {
|
||||||
super(Filterable.class);
|
super(outputClass);
|
||||||
this.elementType = elementType;
|
this.elementType = elementType;
|
||||||
this.optionalElementType = optionalElementType;
|
this.optionalElementType = optionalElementType;
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,13 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
|
|
||||||
public final class FilterableComponent extends Filterable<Tag> {
|
public final class FilterableComponent extends Filterable<Tag> {
|
||||||
|
|
||||||
public static final Type<FilterableComponent> TYPE = new FilterableType<Tag, FilterableComponent>(Type.TAG, Type.OPTIONAL_TAG) {
|
public static final Type<FilterableComponent> TYPE = new FilterableType<Tag, FilterableComponent>(Type.TAG, Type.OPTIONAL_TAG, FilterableComponent.class) {
|
||||||
@Override
|
@Override
|
||||||
protected FilterableComponent create(final Tag raw, final Tag filtered) {
|
protected FilterableComponent create(final Tag raw, final Tag filtered) {
|
||||||
return new FilterableComponent(raw, filtered);
|
return new FilterableComponent(raw, filtered);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final Type<FilterableComponent[]> ARRAY_TYPE = new ArrayType<>(TYPE);
|
public static final Type<FilterableComponent[]> ARRAY_TYPE = new ArrayType<>(FilterableComponent.TYPE);
|
||||||
|
|
||||||
public FilterableComponent(final Tag raw, @Nullable final Tag filtered) {
|
public FilterableComponent(final Tag raw, @Nullable final Tag filtered) {
|
||||||
super(raw, filtered);
|
super(raw, filtered);
|
||||||
|
@ -28,7 +28,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
|
|
||||||
public final class FilterableString extends Filterable<String> {
|
public final class FilterableString extends Filterable<String> {
|
||||||
|
|
||||||
public static final Type<FilterableString> TYPE = new FilterableType<String, FilterableString>(Type.STRING, Type.OPTIONAL_STRING) {
|
public static final Type<FilterableString> TYPE = new FilterableType<String, FilterableString>(Type.STRING, Type.OPTIONAL_STRING, FilterableString.class) {
|
||||||
@Override
|
@Override
|
||||||
protected FilterableString create(final String raw, final String filtered) {
|
protected FilterableString create(final String raw, final String filtered) {
|
||||||
return new FilterableString(raw, filtered);
|
return new FilterableString(raw, filtered);
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data;
|
package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.util.Key;
|
||||||
import com.viaversion.viaversion.util.KeyMappings;
|
import com.viaversion.viaversion.util.KeyMappings;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public final class Attributes1_20_3 {
|
public final class Attributes1_20_5 {
|
||||||
|
|
||||||
private static final KeyMappings ATTRIBUTES = new KeyMappings(
|
private static final KeyMappings ATTRIBUTES = new KeyMappings(
|
||||||
"generic.armor",
|
"generic.armor",
|
||||||
@ -28,22 +29,33 @@ public final class Attributes1_20_3 {
|
|||||||
"generic.attack_damage",
|
"generic.attack_damage",
|
||||||
"generic.attack_knockback",
|
"generic.attack_knockback",
|
||||||
"generic.attack_speed",
|
"generic.attack_speed",
|
||||||
|
"player.block_break_speed",
|
||||||
|
"player.block_interaction_range",
|
||||||
|
"player.entity_interaction_range",
|
||||||
|
"generic.fall_damage_multiplier",
|
||||||
"generic.flying_speed",
|
"generic.flying_speed",
|
||||||
"generic.follow_range",
|
"generic.follow_range",
|
||||||
"horse.jump_strength",
|
"generic.gravity",
|
||||||
|
"generic.jump_strength",
|
||||||
"generic.knockback_resistance",
|
"generic.knockback_resistance",
|
||||||
"generic.luck",
|
"generic.luck",
|
||||||
"generic.max_absorption",
|
"generic.max_absorption",
|
||||||
"generic.max_health",
|
"generic.max_health",
|
||||||
"generic.movement_speed",
|
"generic.movement_speed",
|
||||||
"zombie.spawn_reinforcements"
|
"generic.safe_fall_distance",
|
||||||
|
"generic.scale",
|
||||||
|
"zombie.spawn_reinforcements",
|
||||||
|
"generic.step_height"
|
||||||
);
|
);
|
||||||
|
|
||||||
public static @Nullable String idToKey(final int id) {
|
public static @Nullable String idToKey(final int id) {
|
||||||
return ATTRIBUTES.idToKey(id);
|
return ATTRIBUTES.idToKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int keyToId(final String attribute) {
|
public static int keyToId(String attribute) {
|
||||||
|
if (Key.stripMinecraftNamespace(attribute).equals("horse.jump_strength")) {
|
||||||
|
attribute = "generic.jump_strength";
|
||||||
|
}
|
||||||
return ATTRIBUTES.keyToId(attribute);
|
return ATTRIBUTES.keyToId(attribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,16 +23,16 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
public final class TrimMaterials1_20_3 {
|
public final class TrimMaterials1_20_3 {
|
||||||
|
|
||||||
private static final KeyMappings MATERIALS = new KeyMappings(
|
private static final KeyMappings MATERIALS = new KeyMappings(
|
||||||
"quartz",
|
"amethyst",
|
||||||
"iron",
|
|
||||||
"netherite",
|
|
||||||
"redstone",
|
|
||||||
"copper",
|
"copper",
|
||||||
"gold",
|
|
||||||
"emerald",
|
|
||||||
"diamond",
|
"diamond",
|
||||||
|
"emerald",
|
||||||
|
"quartz",
|
||||||
|
"gold",
|
||||||
|
"iron",
|
||||||
"lapis",
|
"lapis",
|
||||||
"amethyst"
|
"netherite",
|
||||||
|
"redstone"
|
||||||
);
|
);
|
||||||
|
|
||||||
public static @Nullable String idToKey(final int id) {
|
public static @Nullable String idToKey(final int id) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||||
* Copyright (C) 2023 ViaVersion and contributors
|
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -20,27 +20,25 @@ package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data;
|
|||||||
import com.viaversion.viaversion.util.KeyMappings;
|
import com.viaversion.viaversion.util.KeyMappings;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public final class TrimPatterns1_20_5 {
|
public final class TrimPatterns1_20_3 {
|
||||||
|
|
||||||
private static final KeyMappings PATTERNS = new KeyMappings(
|
private static final KeyMappings PATTERNS = new KeyMappings(
|
||||||
"sentry",
|
|
||||||
"dune",
|
|
||||||
"coast",
|
"coast",
|
||||||
"wild",
|
"dune",
|
||||||
"ward",
|
|
||||||
"eye",
|
"eye",
|
||||||
"vex",
|
"host",
|
||||||
"tide",
|
"raiser",
|
||||||
"snout",
|
|
||||||
"rib",
|
"rib",
|
||||||
"spire",
|
"sentry",
|
||||||
"wayfinder",
|
|
||||||
"shaper",
|
"shaper",
|
||||||
"silence",
|
"silence",
|
||||||
"raiser",
|
"snout",
|
||||||
"host",
|
"spire",
|
||||||
"flow",
|
"tide",
|
||||||
"bolt"
|
"vex",
|
||||||
|
"ward",
|
||||||
|
"wayfinder",
|
||||||
|
"wild"
|
||||||
);
|
);
|
||||||
|
|
||||||
public static @Nullable String idToKey(final int id) {
|
public static @Nullable String idToKey(final int id) {
|
@ -73,7 +73,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.Clientb
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.rewriter.RecipeRewriter1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.rewriter.RecipeRewriter1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.DyeColors;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.DyeColors;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Enchantments1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Enchantments1_20_3;
|
||||||
@ -81,7 +81,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Instrumen
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.MapDecorations1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.MapDecorations1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Potions1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Potions1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimMaterials1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimMaterials1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimPatterns1_20_5;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimPatterns1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPacket1_20_5;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPacket1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPackets1_20_5;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPackets1_20_5;
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
@ -233,14 +233,14 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
public @Nullable Item handleItemToClient(@Nullable final Item item) {
|
public @Nullable Item handleItemToClient(@Nullable final Item item) {
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
|
|
||||||
super.handleItemToClient(item);
|
|
||||||
|
|
||||||
// Add the original as custom data, to be re-used for creative clients as well
|
// Add the original as custom data, to be re-used for creative clients as well
|
||||||
final CompoundTag tag = item.tag();
|
final CompoundTag tag = item.tag();
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
tag.putBoolean(nbtTagName(), true);
|
tag.putBoolean(nbtTagName(), true);
|
||||||
}
|
}
|
||||||
return toStructuredItem(item);
|
|
||||||
|
final Item structuredItem = toStructuredItem(item);
|
||||||
|
return super.handleItemToClient(structuredItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -275,7 +275,9 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
final StructuredItem item = new StructuredItem(old.identifier(), (byte) old.amount(), new StructuredDataContainer());
|
final StructuredItem item = new StructuredItem(old.identifier(), (byte) old.amount(), new StructuredDataContainer());
|
||||||
final StructuredDataContainer data = item.structuredData();
|
final StructuredDataContainer data = item.structuredData();
|
||||||
data.setIdLookup(protocol, true);
|
data.setIdLookup(protocol, true);
|
||||||
// TODO add default data if needed (e.g. when getting a goat horn via the give command) :>
|
//TODO add default data if needed, e.g. when getting an item via /give without extra data
|
||||||
|
// Goat horn
|
||||||
|
// (check more)
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@ -464,7 +466,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
holders = HolderSet.of(new int[]{Protocol1_20_5To1_20_3.MAPPINGS.getNewBlockId(id)});
|
holders = HolderSet.of(new int[]{id});
|
||||||
} else {
|
} else {
|
||||||
holders = HolderSet.of(identifier.substring(1));
|
holders = HolderSet.of(identifier.substring(1));
|
||||||
}
|
}
|
||||||
@ -514,12 +516,12 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int operationId = modifierTag.getInt("Operation", -1);
|
final int operationId = modifierTag.getInt("Operation");
|
||||||
if (operationId < 0 || operationId > 2) {
|
if (operationId < 0 || operationId > 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int attributeId = Attributes1_20_3.keyToId(attributeName);
|
final int attributeId = Attributes1_20_5.keyToId(attributeName);
|
||||||
if (attributeId == -1) {
|
if (attributeId == -1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -592,6 +594,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
final Tag materialTag = trimTag.get("material");
|
final Tag materialTag = trimTag.get("material");
|
||||||
final Holder<ArmorTrimMaterial> materialHolder;
|
final Holder<ArmorTrimMaterial> materialHolder;
|
||||||
if (materialTag instanceof StringTag) {
|
if (materialTag instanceof StringTag) {
|
||||||
|
// Would technically have to be stored and retreived from registry data, but that'd mean a lot of work
|
||||||
final int id = TrimMaterials1_20_3.keyToId(((StringTag) materialTag).getValue());
|
final int id = TrimMaterials1_20_3.keyToId(((StringTag) materialTag).getValue());
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
return;
|
return;
|
||||||
@ -638,7 +641,8 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
final Tag patternTag = trimTag.get("pattern");
|
final Tag patternTag = trimTag.get("pattern");
|
||||||
final Holder<ArmorTrimPattern> patternHolder;
|
final Holder<ArmorTrimPattern> patternHolder;
|
||||||
if (patternTag instanceof StringTag) {
|
if (patternTag instanceof StringTag) {
|
||||||
final int id = TrimPatterns1_20_5.keyToId(((StringTag) patternTag).getValue());
|
// Would technically have to be stored and retreived from registry data, but that'd mean a lot of work
|
||||||
|
final int id = TrimPatterns1_20_3.keyToId(((StringTag) patternTag).getValue());
|
||||||
if (id == -1) {
|
if (id == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -841,8 +845,6 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.remove(key);
|
|
||||||
|
|
||||||
final Enchantments enchantments = new Enchantments(new Int2IntOpenHashMap(), show);
|
final Enchantments enchantments = new Enchantments(new Int2IntOpenHashMap(), show);
|
||||||
for (final CompoundTag enchantment : enchantmentsTag) {
|
for (final CompoundTag enchantment : enchantmentsTag) {
|
||||||
final String id = enchantment.getString("id");
|
final String id = enchantment.getString("id");
|
||||||
@ -862,7 +864,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
data.set(newKey, enchantments);
|
data.set(newKey, enchantments);
|
||||||
|
|
||||||
// Add glint if none of the enchantments were valid
|
// Add glint if none of the enchantments were valid
|
||||||
if (enchantments.size() == 0 && !enchantmentsTag.isEmpty()) {
|
if (!enchantmentsTag.isEmpty() && enchantments.size() == 0) {
|
||||||
data.set(StructuredDataKey.ENCHANTMENT_GLINT_OVERRIDE, true);
|
data.set(StructuredDataKey.ENCHANTMENT_GLINT_OVERRIDE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1011,6 +1013,13 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
containerLoot.putLong("loot_table_seed", lootTableSeed);
|
containerLoot.putLong("loot_table_seed", lootTableSeed);
|
||||||
data.set(StructuredDataKey.CONTAINER_LOOT, containerLoot);
|
data.set(StructuredDataKey.CONTAINER_LOOT, containerLoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Tag baseColorTag = tag.remove("Base");
|
||||||
|
if (baseColorTag instanceof NumberTag) {
|
||||||
|
data.set(StructuredDataKey.BASE_COLOR, ((NumberTag) baseColorTag).asInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
updateItemList(data, tag, "Items", StructuredDataKey.CONTAINER);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Tag skullOwnerTag = tag.remove("SkullOwner");
|
final Tag skullOwnerTag = tag.remove("SkullOwner");
|
||||||
@ -1022,14 +1031,6 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
updateSkullOwnerTag(tag, (CompoundTag) skullOwnerTag);
|
updateSkullOwnerTag(tag, (CompoundTag) skullOwnerTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Tag baseColorTag = tag.remove("Base");
|
|
||||||
if (baseColorTag instanceof NumberTag) {
|
|
||||||
tag.put("base_color", baseColorTag);
|
|
||||||
if (data != null) {
|
|
||||||
data.set(StructuredDataKey.BASE_COLOR, ((NumberTag) baseColorTag).asInt());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final ListTag<CompoundTag> patternsTag = tag.getListTag("Patterns", CompoundTag.class);
|
final ListTag<CompoundTag> patternsTag = tag.getListTag("Patterns", CompoundTag.class);
|
||||||
if (patternsTag != null) {
|
if (patternsTag != null) {
|
||||||
final BannerPatternLayer[] layers = patternsTag.stream().map(patternTag -> {
|
final BannerPatternLayer[] layers = patternsTag.stream().map(patternTag -> {
|
||||||
@ -1055,8 +1056,6 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
data.set(StructuredDataKey.BANNER_PATTERNS, layers);
|
data.set(StructuredDataKey.BANNER_PATTERNS, layers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateItemList(data, tag, "Items", StructuredDataKey.CONTAINER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSkullOwnerTag(final CompoundTag tag, final CompoundTag skullOwnerTag) {
|
private void updateSkullOwnerTag(final CompoundTag tag, final CompoundTag skullOwnerTag) {
|
||||||
|
@ -35,11 +35,10 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.Clientb
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPacket1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPacket1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundConfigurationPackets1_20_5;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundConfigurationPackets1_20_5;
|
||||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||||
import com.viaversion.viaversion.util.Key;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -67,14 +66,14 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
|||||||
|
|
||||||
for (final Map.Entry<String, Tag> entry : registryData.entrySet()) {
|
for (final Map.Entry<String, Tag> entry : registryData.entrySet()) {
|
||||||
final CompoundTag entryTag = (CompoundTag) entry.getValue();
|
final CompoundTag entryTag = (CompoundTag) entry.getValue();
|
||||||
final StringTag typeTag = entryTag.getStringTag("type");
|
final String type = entryTag.getString("type");
|
||||||
final ListTag<CompoundTag> valueTag = entryTag.getListTag("value", CompoundTag.class);
|
final ListTag<CompoundTag> valueTag = entryTag.getListTag("value", CompoundTag.class);
|
||||||
RegistryEntry[] registryEntries = new RegistryEntry[valueTag.size()];
|
RegistryEntry[] registryEntries = new RegistryEntry[valueTag.size()];
|
||||||
boolean requiresDummyValues = false;
|
boolean requiresDummyValues = false;
|
||||||
int entriesLength = registryEntries.length;
|
int entriesLength = registryEntries.length;
|
||||||
for (final CompoundTag tag : valueTag) {
|
for (final CompoundTag tag : valueTag) {
|
||||||
final StringTag nameTag = tag.getStringTag("name");
|
final String name = tag.getString("name");
|
||||||
final int id = tag.getNumberTag("id").asInt();
|
final int id = tag.getInt("id");
|
||||||
entriesLength = Math.max(entriesLength, id + 1);
|
entriesLength = Math.max(entriesLength, id + 1);
|
||||||
if (id >= registryEntries.length) {
|
if (id >= registryEntries.length) {
|
||||||
// It was previously possible to have arbitrary ids
|
// It was previously possible to have arbitrary ids
|
||||||
@ -82,7 +81,7 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
|||||||
requiresDummyValues = true;
|
requiresDummyValues = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
registryEntries[id] = new RegistryEntry(nameTag.getValue(), tag.get("element"));
|
registryEntries[id] = new RegistryEntry(name, tag.get("element"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requiresDummyValues) {
|
if (requiresDummyValues) {
|
||||||
@ -94,7 +93,7 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
|||||||
}
|
}
|
||||||
|
|
||||||
final PacketWrapper registryPacket = wrapper.create(ClientboundConfigurationPackets1_20_5.REGISTRY_DATA);
|
final PacketWrapper registryPacket = wrapper.create(ClientboundConfigurationPackets1_20_5.REGISTRY_DATA);
|
||||||
registryPacket.write(Type.STRING, typeTag.getValue());
|
registryPacket.write(Type.STRING, type);
|
||||||
registryPacket.write(Type.REGISTRY_ENTRY_ARRAY, registryEntries);
|
registryPacket.write(Type.REGISTRY_ENTRY_ARRAY, registryEntries);
|
||||||
registryPacket.send(Protocol1_20_5To1_20_3.class);
|
registryPacket.send(Protocol1_20_5To1_20_3.class);
|
||||||
}
|
}
|
||||||
@ -155,6 +154,7 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
|||||||
map(Type.VAR_INT); // Portal cooldown
|
map(Type.VAR_INT); // Portal cooldown
|
||||||
create(Type.BOOLEAN, false); // Enforces secure chat - moved from server data (which is unfortunately sent a while after this)
|
create(Type.BOOLEAN, false); // Enforces secure chat - moved from server data (which is unfortunately sent a while after this)
|
||||||
handler(worldDataTrackerHandlerByKey1_20_5(3)); // Tracks world height and name for chunk data and entity (un)tracking
|
handler(worldDataTrackerHandlerByKey1_20_5(3)); // Tracks world height and name for chunk data and entity (un)tracking
|
||||||
|
handler(playerTrackerHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -184,9 +184,9 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
|||||||
final int size = wrapper.passthrough(Type.VAR_INT);
|
final int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
// From a string to a registry int ID
|
// From a string to a registry int ID
|
||||||
final String attributeIdentifier = Key.stripMinecraftNamespace(wrapper.read(Type.STRING));
|
final String attributeIdentifier = wrapper.read(Type.STRING);
|
||||||
final int id = Attributes1_20_3.keyToId(attributeIdentifier);
|
final int id = Attributes1_20_5.keyToId(attributeIdentifier);
|
||||||
wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewAttributeId(id));
|
wrapper.write(Type.VAR_INT, id != -1 ? id : 0);
|
||||||
|
|
||||||
wrapper.passthrough(Type.DOUBLE); // Base
|
wrapper.passthrough(Type.DOUBLE); // Base
|
||||||
final int modifierSize = wrapper.passthrough(Type.VAR_INT);
|
final int modifierSize = wrapper.passthrough(Type.VAR_INT);
|
||||||
@ -220,13 +220,13 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
|||||||
protected void registerRewrites() {
|
protected void registerRewrites() {
|
||||||
filter().mapMetaType(typeId -> {
|
filter().mapMetaType(typeId -> {
|
||||||
int id = typeId;
|
int id = typeId;
|
||||||
if (typeId >= Types1_20_5.META_TYPES.particlesType.typeId()) {
|
if (id >= Types1_20_5.META_TYPES.particlesType.typeId()) {
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
if (typeId >= Types1_20_5.META_TYPES.armadilloState.typeId()) {
|
if (id >= Types1_20_5.META_TYPES.wolfVariantType.typeId()) {
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
if (typeId >= Types1_20_5.META_TYPES.wolfVariantType.typeId()) {
|
if (id >= Types1_20_5.META_TYPES.armadilloState.typeId()) {
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
return Types1_20_5.META_TYPES.byId(id);
|
return Types1_20_5.META_TYPES.byId(id);
|
||||||
@ -259,7 +259,7 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
|||||||
public void rewriteParticle(final Particle particle) {
|
public void rewriteParticle(final Particle particle) {
|
||||||
super.rewriteParticle(particle);
|
super.rewriteParticle(particle);
|
||||||
if (particle.id() == protocol.getMappingData().getParticleMappings().mappedId("entity_effect")) {
|
if (particle.id() == protocol.getMappingData().getParticleMappings().mappedId("entity_effect")) {
|
||||||
particle.add(Type.INT, 0); // rgb
|
particle.add(Type.INT, 0); // rgb // TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ import com.viaversion.viaversion.api.minecraft.item.data.StatePropertyMatcher;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.data.SuspiciousStewEffect;
|
import com.viaversion.viaversion.api.minecraft.item.data.SuspiciousStewEffect;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.util.PotionEffects;
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.util.PotionEffects;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Enchantments1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Enchantments1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Instruments1_20_3;
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Instruments1_20_3;
|
||||||
@ -94,13 +94,13 @@ final class StructuredDataConverter {
|
|||||||
register(StructuredDataKey.ATTRIBUTE_MODIFIERS, (data, tag) -> {
|
register(StructuredDataKey.ATTRIBUTE_MODIFIERS, (data, tag) -> {
|
||||||
final ListTag<CompoundTag> modifiers = new ListTag<>(CompoundTag.class);
|
final ListTag<CompoundTag> modifiers = new ListTag<>(CompoundTag.class);
|
||||||
for (final AttributeModifier modifier : data.modifiers()) {
|
for (final AttributeModifier modifier : data.modifiers()) {
|
||||||
final String identifier = Attributes1_20_3.idToKey(modifier.attribute());
|
final String identifier = Attributes1_20_5.idToKey(modifier.attribute());
|
||||||
if (identifier == null) {
|
if (identifier == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CompoundTag modifierTag = new CompoundTag();
|
final CompoundTag modifierTag = new CompoundTag();
|
||||||
modifierTag.putString("AttributeName", identifier);
|
modifierTag.putString("AttributeName", identifier.equals("generic.jump_strength") ? "horse.jump_strength" : identifier);
|
||||||
modifierTag.putString("Name", modifier.modifier().name());
|
modifierTag.putString("Name", modifier.modifier().name());
|
||||||
modifierTag.putDouble("Amount", modifier.modifier().amount());
|
modifierTag.putDouble("Amount", modifier.modifier().amount());
|
||||||
modifierTag.putInt("Slot", modifier.slotType());
|
modifierTag.putInt("Slot", modifier.slotType());
|
||||||
|
@ -68,6 +68,7 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
|
|||||||
map(Type.VAR_INT); // Dimension id
|
map(Type.VAR_INT); // Dimension id
|
||||||
map(Type.STRING); // World
|
map(Type.STRING); // World
|
||||||
handler(worldDataTrackerHandlerByKey1_20_5(3)); // Tracks world height and name for chunk data and entity (un)tracking
|
handler(worldDataTrackerHandlerByKey1_20_5(3)); // Tracks world height and name for chunk data and entity (un)tracking
|
||||||
|
handler(playerTrackerHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren