mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 03:25:11 +01:00
Banner patterns and wolves
This commit is contained in:
parent
121f107ff3
commit
bfab9b0c11
@ -33,31 +33,31 @@ public final class BannerPatternLayer {
|
|||||||
@Override
|
@Override
|
||||||
public BannerPatternLayer read(final ByteBuf buffer) throws Exception {
|
public BannerPatternLayer read(final ByteBuf buffer) throws Exception {
|
||||||
final Holder<BannerPattern> pattern = BannerPattern.TYPE.read(buffer);
|
final Holder<BannerPattern> pattern = BannerPattern.TYPE.read(buffer);
|
||||||
final DyedColor color = DyedColor.TYPE.read(buffer);
|
final int color = Type.VAR_INT.readPrimitive(buffer);
|
||||||
return new BannerPatternLayer(pattern, color);
|
return new BannerPatternLayer(pattern, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(final ByteBuf buffer, final BannerPatternLayer value) throws Exception {
|
public void write(final ByteBuf buffer, final BannerPatternLayer value) throws Exception {
|
||||||
BannerPattern.TYPE.write(buffer, value.pattern);
|
BannerPattern.TYPE.write(buffer, value.pattern);
|
||||||
DyedColor.TYPE.write(buffer, value.color);
|
Type.VAR_INT.writePrimitive(buffer, value.dyeColor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final Type<BannerPatternLayer[]> ARRAY_TYPE = new ArrayType<>(TYPE);
|
public static final Type<BannerPatternLayer[]> ARRAY_TYPE = new ArrayType<>(TYPE);
|
||||||
|
|
||||||
private final Holder<BannerPattern> pattern;
|
private final Holder<BannerPattern> pattern;
|
||||||
private final DyedColor color;
|
private final int dyeColor;
|
||||||
|
|
||||||
public BannerPatternLayer(final Holder<BannerPattern> pattern, final DyedColor color) {
|
public BannerPatternLayer(final Holder<BannerPattern> pattern, final int dyeColor) {
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
this.color = color;
|
this.dyeColor = dyeColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Holder<BannerPattern> pattern() {
|
public Holder<BannerPattern> pattern() {
|
||||||
return pattern;
|
return pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DyedColor color() {
|
public int dyeColor() {
|
||||||
return color;
|
return dyeColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||||
|
* 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.viaversion.protocols.protocol1_20_5to1_20_3.data;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.util.KeyMappings;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
public final class BannerPatterns1_20_3 {
|
||||||
|
|
||||||
|
private static final KeyMappings PATTERNS = new KeyMappings(
|
||||||
|
"base",
|
||||||
|
"square_bottom_left",
|
||||||
|
"square_bottom_right",
|
||||||
|
"square_top_left",
|
||||||
|
"square_top_right",
|
||||||
|
"stripe_bottom",
|
||||||
|
"stripe_top",
|
||||||
|
"stripe_left",
|
||||||
|
"stripe_right",
|
||||||
|
"stripe_center",
|
||||||
|
"stripe_middle",
|
||||||
|
"stripe_downright",
|
||||||
|
"stripe_downleft",
|
||||||
|
"small_stripes",
|
||||||
|
"cross",
|
||||||
|
"straight_cross",
|
||||||
|
"triangle_bottom",
|
||||||
|
"triangle_top",
|
||||||
|
"triangles_bottom",
|
||||||
|
"triangles_top",
|
||||||
|
"diagonal_left",
|
||||||
|
"diagonal_up_right",
|
||||||
|
"diagonal_up_left",
|
||||||
|
"diagonal_right",
|
||||||
|
"circle",
|
||||||
|
"rhombus",
|
||||||
|
"half_vertical",
|
||||||
|
"half_horizontal",
|
||||||
|
"half_vertical_right",
|
||||||
|
"half_horizontal_bottom",
|
||||||
|
"border",
|
||||||
|
"curly_border",
|
||||||
|
"gradient",
|
||||||
|
"gradient_up",
|
||||||
|
"bricks",
|
||||||
|
"globe",
|
||||||
|
"creeper",
|
||||||
|
"skull",
|
||||||
|
"flower",
|
||||||
|
"mojang",
|
||||||
|
"piglin"
|
||||||
|
);
|
||||||
|
private static final Map<String, String> PATTERN_IDS = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
PATTERN_IDS.put("b", "base");
|
||||||
|
PATTERN_IDS.put("bl", "square_bottom_left");
|
||||||
|
PATTERN_IDS.put("br", "square_bottom_right");
|
||||||
|
PATTERN_IDS.put("tl", "square_top_left");
|
||||||
|
PATTERN_IDS.put("tr", "square_top_right");
|
||||||
|
PATTERN_IDS.put("bs", "stripe_bottom");
|
||||||
|
PATTERN_IDS.put("ts", "stripe_top");
|
||||||
|
PATTERN_IDS.put("ls", "stripe_left");
|
||||||
|
PATTERN_IDS.put("rs", "stripe_right");
|
||||||
|
PATTERN_IDS.put("cs", "stripe_center");
|
||||||
|
PATTERN_IDS.put("ms", "stripe_middle");
|
||||||
|
PATTERN_IDS.put("drs", "stripe_downright");
|
||||||
|
PATTERN_IDS.put("dls", "stripe_downleft");
|
||||||
|
PATTERN_IDS.put("ss", "small_stripes");
|
||||||
|
PATTERN_IDS.put("cr", "cross");
|
||||||
|
PATTERN_IDS.put("sc", "straight_cross");
|
||||||
|
PATTERN_IDS.put("bt", "triangle_bottom");
|
||||||
|
PATTERN_IDS.put("tt", "triangle_top");
|
||||||
|
PATTERN_IDS.put("bts", "triangles_bottom");
|
||||||
|
PATTERN_IDS.put("tts", "triangles_top");
|
||||||
|
PATTERN_IDS.put("ld", "diagonal_left");
|
||||||
|
PATTERN_IDS.put("rd", "diagonal_up_right");
|
||||||
|
PATTERN_IDS.put("lud", "diagonal_up_left");
|
||||||
|
PATTERN_IDS.put("rud", "diagonal_right");
|
||||||
|
PATTERN_IDS.put("mc", "circle");
|
||||||
|
PATTERN_IDS.put("mr", "rhombus");
|
||||||
|
PATTERN_IDS.put("vh", "half_vertical");
|
||||||
|
PATTERN_IDS.put("hh", "half_horizontal");
|
||||||
|
PATTERN_IDS.put("vhr", "half_vertical_right");
|
||||||
|
PATTERN_IDS.put("hhb", "half_horizontal_bottom");
|
||||||
|
PATTERN_IDS.put("bo", "border");
|
||||||
|
PATTERN_IDS.put("cbo", "curly_border");
|
||||||
|
PATTERN_IDS.put("gra", "gradient");
|
||||||
|
PATTERN_IDS.put("gru", "gradient_up");
|
||||||
|
PATTERN_IDS.put("bri", "bricks");
|
||||||
|
PATTERN_IDS.put("glb", "globe");
|
||||||
|
PATTERN_IDS.put("cre", "creeper");
|
||||||
|
PATTERN_IDS.put("sku", "skull");
|
||||||
|
PATTERN_IDS.put("flo", "flower");
|
||||||
|
PATTERN_IDS.put("moj", "mojang");
|
||||||
|
PATTERN_IDS.put("pig", "piglin");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable String idToKey(final int id) {
|
||||||
|
return PATTERNS.idToKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int keyToId(final String pattern) {
|
||||||
|
return PATTERNS.keyToId(pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable String compactToFullId(final String compactId) {
|
||||||
|
return PATTERN_IDS.get(compactId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] keys() {
|
||||||
|
return PATTERNS.keys();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data;
|
||||||
|
|
||||||
|
public final class DyeColors {
|
||||||
|
|
||||||
|
public static String colorById(final int id) {
|
||||||
|
switch (id) {
|
||||||
|
case 1:
|
||||||
|
return "orange";
|
||||||
|
case 2:
|
||||||
|
return "magenta";
|
||||||
|
case 3:
|
||||||
|
return "light_blue";
|
||||||
|
case 4:
|
||||||
|
return "yellow";
|
||||||
|
case 5:
|
||||||
|
return "lime";
|
||||||
|
case 6:
|
||||||
|
return "pink";
|
||||||
|
case 7:
|
||||||
|
return "gray";
|
||||||
|
case 8:
|
||||||
|
return "light_gray";
|
||||||
|
case 9:
|
||||||
|
return "cyan";
|
||||||
|
case 10:
|
||||||
|
return "purple";
|
||||||
|
case 11:
|
||||||
|
return "blue";
|
||||||
|
case 12:
|
||||||
|
return "brown";
|
||||||
|
case 13:
|
||||||
|
return "green";
|
||||||
|
case 14:
|
||||||
|
return "red";
|
||||||
|
case 15:
|
||||||
|
return "black";
|
||||||
|
default:
|
||||||
|
return "white";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -68,7 +68,7 @@ public final class Enchantments1_20_3 {
|
|||||||
return ENCHANTMENTS.idToKey(id);
|
return ENCHANTMENTS.idToKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int id(final String attribute) {
|
public static int id(final String enchantment) {
|
||||||
return ENCHANTMENTS.keyToId(attribute);
|
return ENCHANTMENTS.keyToId(enchantment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public final class MapDecorations1_20_3 {
|
|||||||
"swamp_hut"
|
"swamp_hut"
|
||||||
);
|
);
|
||||||
|
|
||||||
public static String mapDecoration(final int index) {
|
public static String idToKey(final int index) {
|
||||||
return index < 0 || index >= MAP_DECORATIONS.size() ? "player" : MAP_DECORATIONS.idToKey(index);
|
return index < 0 || index >= MAP_DECORATIONS.size() ? "player" : MAP_DECORATIONS.idToKey(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public final class Potions1_20_3 {
|
|||||||
return POTIONS.idToKey(id);
|
return POTIONS.idToKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int keyToId(final String attribute) {
|
public static int keyToId(final String potion) {
|
||||||
return POTIONS.keyToId(attribute);
|
return POTIONS.keyToId(potion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public final class TrimMaterials1_20_3 {
|
|||||||
return MATERIALS.idToKey(id);
|
return MATERIALS.idToKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int keyToId(final String attribute) {
|
public static int keyToId(final String material) {
|
||||||
return MATERIALS.keyToId(attribute);
|
return MATERIALS.keyToId(material);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public final class TrimPatterns1_20_3 {
|
|||||||
return PATTERNS.idToKey(id);
|
return PATTERNS.idToKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int keyToId(final String attribute) {
|
public static int keyToId(final String pattern) {
|
||||||
return PATTERNS.keyToId(attribute);
|
return PATTERNS.keyToId(pattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrimMaterial;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrimPattern;
|
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrimPattern;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifier;
|
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifier;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers;
|
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.BlockStateProperties;
|
import com.viaversion.viaversion.api.minecraft.item.data.BlockStateProperties;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.DyedColor;
|
import com.viaversion.viaversion.api.minecraft.item.data.DyedColor;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.Enchantments;
|
import com.viaversion.viaversion.api.minecraft.item.data.Enchantments;
|
||||||
@ -64,6 +65,8 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.Clientb
|
|||||||
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_3;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_3;
|
||||||
|
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;
|
||||||
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;
|
||||||
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;
|
||||||
@ -79,6 +82,7 @@ import com.viaversion.viaversion.util.Key;
|
|||||||
import com.viaversion.viaversion.util.UUIDUtil;
|
import com.viaversion.viaversion.util.UUIDUtil;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -251,7 +255,6 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
return dataItem;
|
return dataItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Block entity changes
|
|
||||||
public Item toStructuredItem(final Item old) {
|
public Item toStructuredItem(final Item old) {
|
||||||
final CompoundTag tag = old.tag();
|
final CompoundTag tag = old.tag();
|
||||||
final StructuredItem item = new StructuredItem(old.identifier(), (byte) old.amount(), new StructuredDataContainer());
|
final StructuredItem item = new StructuredItem(old.identifier(), (byte) old.amount(), new StructuredDataContainer());
|
||||||
@ -263,8 +266,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rewrite nbt to new data structures
|
// Rewrite nbt to new data structures
|
||||||
final NumberTag hideFlags = tag.getNumberTag("HideFlags");
|
final int hideFlagsValue = tag.getInt("HideFlags");
|
||||||
final int hideFlagsValue = hideFlags != null ? hideFlags.asInt() : 0;
|
|
||||||
if ((hideFlagsValue & 0x20) != 0) {
|
if ((hideFlagsValue & 0x20) != 0) {
|
||||||
data.set(StructuredDataKey.HIDE_ADDITIONAL_TOOLTIP);
|
data.set(StructuredDataKey.HIDE_ADDITIONAL_TOOLTIP);
|
||||||
}
|
}
|
||||||
@ -329,9 +331,9 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
}
|
}
|
||||||
|
|
||||||
final CompoundTag lodestonePosTag = tag.getCompoundTag("LodestonePos");
|
final CompoundTag lodestonePosTag = tag.getCompoundTag("LodestonePos");
|
||||||
final StringTag lodestoneDimensionTag = tag.getStringTag("LodestoneDimension");
|
final String lodestoneDimension = tag.getString("LodestoneDimension");
|
||||||
if (lodestonePosTag != null && lodestoneDimensionTag != null) {
|
if (lodestonePosTag != null && lodestoneDimension != null) {
|
||||||
updateLodestoneTracker(tag, lodestonePosTag, lodestoneDimensionTag, data);
|
updateLodestoneTracker(tag, lodestonePosTag, lodestoneDimension, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ListTag<CompoundTag> effectsTag = tag.getListTag("effects", CompoundTag.class);
|
final ListTag<CompoundTag> effectsTag = tag.getListTag("effects", CompoundTag.class);
|
||||||
@ -339,9 +341,9 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
updateEffects(effectsTag, data);
|
updateEffects(effectsTag, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringTag instrumentTag = tag.getStringTag("instrument");
|
final String instrument = tag.getString("instrument");
|
||||||
if (instrumentTag != null) {
|
if (instrument != null) {
|
||||||
final int id = Instruments1_20_3.keyToId(instrumentTag.getValue());
|
final int id = Instruments1_20_3.keyToId(instrument);
|
||||||
if (id != -1) {
|
if (id != -1) {
|
||||||
data.set(StructuredDataKey.INSTRUMENT, Holder.of(id));
|
data.set(StructuredDataKey.INSTRUMENT, Holder.of(id));
|
||||||
}
|
}
|
||||||
@ -396,8 +398,6 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
// StructuredDataKey.CREATIVE_SLOT_LOCK
|
// StructuredDataKey.CREATIVE_SLOT_LOCK
|
||||||
// StructuredDataKey.INTANGIBLE_PROJECTILE
|
// StructuredDataKey.INTANGIBLE_PROJECTILE
|
||||||
// StructuredDataKey.NOTE_BLOCK_SOUND
|
// StructuredDataKey.NOTE_BLOCK_SOUND
|
||||||
// StructuredDataKey.BANNER_PATTERNS
|
|
||||||
// StructuredDataKey.BASE_COLOR
|
|
||||||
// StructuredDataKey.POT_DECORATIONS
|
// StructuredDataKey.POT_DECORATIONS
|
||||||
// StructuredDataKey.CONTAINER
|
// StructuredDataKey.CONTAINER
|
||||||
// StructuredDataKey.BEES
|
// StructuredDataKey.BEES
|
||||||
@ -410,22 +410,21 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
|
|
||||||
private void updateAttributes(final StructuredDataContainer data, final ListTag<CompoundTag> attributeModifiersTag, final boolean showInTooltip) {
|
private void updateAttributes(final StructuredDataContainer data, final ListTag<CompoundTag> attributeModifiersTag, final boolean showInTooltip) {
|
||||||
final AttributeModifier[] modifiers = attributeModifiersTag.stream().map(modifierTag -> {
|
final AttributeModifier[] modifiers = attributeModifiersTag.stream().map(modifierTag -> {
|
||||||
final StringTag attributeNameTag = modifierTag.getStringTag("AttributeName");
|
final String attributeName = modifierTag.getString("AttributeName");
|
||||||
final StringTag nameTag = modifierTag.getStringTag("Name");
|
final String name = modifierTag.getString("Name");
|
||||||
final NumberTag operationTag = modifierTag.getNumberTag("Operation");
|
|
||||||
final NumberTag amountTag = modifierTag.getNumberTag("Amount");
|
final NumberTag amountTag = modifierTag.getNumberTag("Amount");
|
||||||
final IntArrayTag uuidTag = modifierTag.getIntArrayTag("UUID");
|
final IntArrayTag uuidTag = modifierTag.getIntArrayTag("UUID");
|
||||||
final NumberTag slotTag = modifierTag.getNumberTag("Slot");
|
final NumberTag slotTag = modifierTag.getNumberTag("Slot");
|
||||||
if (nameTag == null || attributeNameTag == null || operationTag == null || amountTag == null || uuidTag == null || slotTag == null) {
|
if (name == null || attributeName == null || amountTag == null || uuidTag == null || slotTag == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int operationId = operationTag.asInt();
|
final int operationId = modifierTag.getInt("Operation", -1);
|
||||||
if (operationId < 0 || operationId > 2) {
|
if (operationId < 0 || operationId > 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int attributeId = Attributes1_20_3.keyToId(attributeNameTag.getValue());
|
final int attributeId = Attributes1_20_3.keyToId(attributeName);
|
||||||
if (attributeId == -1) {
|
if (attributeId == -1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -434,7 +433,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
attributeId,
|
attributeId,
|
||||||
new ModifierData(
|
new ModifierData(
|
||||||
UUIDUtil.fromIntArray(uuidTag.getValue()),
|
UUIDUtil.fromIntArray(uuidTag.getValue()),
|
||||||
nameTag.getValue(),
|
name,
|
||||||
amountTag.asDouble(),
|
amountTag.asDouble(),
|
||||||
operationId
|
operationId
|
||||||
),
|
),
|
||||||
@ -445,10 +444,10 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePotionTags(final StructuredDataContainer data, final CompoundTag tag) {
|
private void updatePotionTags(final StructuredDataContainer data, final CompoundTag tag) {
|
||||||
final StringTag potionTag = tag.getStringTag("Potion");
|
final String potion = tag.getString("Potion");
|
||||||
Integer potionId = null;
|
Integer potionId = null;
|
||||||
if (potionTag != null) {
|
if (potion != null) {
|
||||||
final int id = Potions1_20_3.keyToId(potionTag.getValue());
|
final int id = Potions1_20_3.keyToId(potion);
|
||||||
potionId = id > 0 ? id - 1 : null; // Empty potion type removed
|
potionId = id > 0 ? id - 1 : null; // Empty potion type removed
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,27 +456,27 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
PotionEffect[] potionEffects = null;
|
PotionEffect[] potionEffects = null;
|
||||||
if (customPotionEffectsTag != null) {
|
if (customPotionEffectsTag != null) {
|
||||||
potionEffects = customPotionEffectsTag.stream().map(effectTag -> {
|
potionEffects = customPotionEffectsTag.stream().map(effectTag -> {
|
||||||
final StringTag idTag = effectTag.getStringTag("id");
|
final String identifier = effectTag.getString("id");
|
||||||
if (idTag == null) {
|
if (identifier == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int id = PotionEffects.keyToId(idTag.getValue()) - 1;
|
final int id = PotionEffects.keyToId(identifier) - 1;
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final NumberTag amplifierTag = effectTag.getNumberTag("amplifier");
|
final byte amplifier = effectTag.getByte("amplifier");
|
||||||
final NumberTag durationTag = effectTag.getNumberTag("duration");
|
final int duration = effectTag.getInt("duration");
|
||||||
final NumberTag ambientTag = effectTag.getNumberTag("ambient");
|
final boolean ambient = effectTag.getBoolean("ambient");
|
||||||
final NumberTag showParticlesTag = effectTag.getNumberTag("show_particles");
|
final boolean showParticles = effectTag.getBoolean("show_particles");
|
||||||
final NumberTag showIconTag = effectTag.getNumberTag("show_icon");
|
final boolean showIcon = effectTag.getBoolean("show_icon");
|
||||||
final PotionEffectData effectData = new PotionEffectData(
|
final PotionEffectData effectData = new PotionEffectData(
|
||||||
amplifierTag != null ? amplifierTag.asByte() : 0,
|
amplifier,
|
||||||
durationTag != null ? durationTag.asInt() : 0,
|
duration,
|
||||||
ambientTag != null && ambientTag.asBoolean(),
|
ambient,
|
||||||
showParticlesTag != null && showParticlesTag.asBoolean(),
|
showParticles,
|
||||||
showIconTag != null && showIconTag.asBoolean(),
|
showIcon,
|
||||||
null //TODO
|
null //TODO
|
||||||
);
|
);
|
||||||
return new PotionEffect(id, effectData);
|
return new PotionEffect(id, effectData);
|
||||||
@ -557,9 +556,9 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateFireworks(final StructuredDataContainer data, final CompoundTag fireworksTag, final ListTag<CompoundTag> explosionsTag) {
|
private void updateFireworks(final StructuredDataContainer data, final CompoundTag fireworksTag, final ListTag<CompoundTag> explosionsTag) {
|
||||||
final NumberTag flightDuration = fireworksTag.getNumberTag("Flight");
|
final int flightDuration = fireworksTag.getInt("Flight");
|
||||||
final Fireworks fireworks = new Fireworks(
|
final Fireworks fireworks = new Fireworks(
|
||||||
flightDuration != null ? flightDuration.asInt() : 0,
|
flightDuration,
|
||||||
explosionsTag.stream().map(this::readExplosion).toArray(FireworkExplosion[]::new)
|
explosionsTag.stream().map(this::readExplosion).toArray(FireworkExplosion[]::new)
|
||||||
);
|
);
|
||||||
data.set(StructuredDataKey.FIREWORKS, fireworks);
|
data.set(StructuredDataKey.FIREWORKS, fireworks);
|
||||||
@ -569,43 +568,38 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
final SuspiciousStewEffect[] suspiciousStewEffects = new SuspiciousStewEffect[effects.size()];
|
final SuspiciousStewEffect[] suspiciousStewEffects = new SuspiciousStewEffect[effects.size()];
|
||||||
for (int i = 0; i < effects.size(); i++) {
|
for (int i = 0; i < effects.size(); i++) {
|
||||||
final CompoundTag effect = effects.get(i);
|
final CompoundTag effect = effects.get(i);
|
||||||
final StringTag effectId = effect.getStringTag("id");
|
final String effectId = effect.getString("id", "luck");
|
||||||
final NumberTag duration = effect.getNumberTag("duration");
|
final int duration = effect.getInt("duration");
|
||||||
final SuspiciousStewEffect stewEffect = new SuspiciousStewEffect(
|
final SuspiciousStewEffect stewEffect = new SuspiciousStewEffect(
|
||||||
PotionEffects.keyToId(effectId != null ? effectId.getValue() : "luck") - 1,
|
PotionEffects.keyToId(effectId) - 1,
|
||||||
duration != null ? duration.asInt() : 0
|
duration
|
||||||
);
|
);
|
||||||
suspiciousStewEffects[i] = stewEffect;
|
suspiciousStewEffects[i] = stewEffect;
|
||||||
}
|
}
|
||||||
data.set(StructuredDataKey.SUSPICIOUS_STEW_EFFECTS, suspiciousStewEffects);
|
data.set(StructuredDataKey.SUSPICIOUS_STEW_EFFECTS, suspiciousStewEffects);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLodestoneTracker(final CompoundTag tag, final CompoundTag lodestonePosTag, final StringTag lodestoneDimensionTag, final StructuredDataContainer data) {
|
private void updateLodestoneTracker(final CompoundTag tag, final CompoundTag lodestonePosTag, final String lodestoneDimensionTag, final StructuredDataContainer data) {
|
||||||
final NumberTag trackedTag = tag.getNumberTag("LodestoneTracked");
|
final boolean tracked = tag.getBoolean("LodestoneTracked");
|
||||||
final NumberTag xTag = lodestonePosTag.getNumberTag("X");
|
final int x = lodestonePosTag.getInt("X");
|
||||||
final NumberTag yTag = lodestonePosTag.getNumberTag("Y");
|
final int y = lodestonePosTag.getInt("Y");
|
||||||
final NumberTag zTag = lodestonePosTag.getNumberTag("Z");
|
final int z = lodestonePosTag.getInt("Z");
|
||||||
final GlobalPosition position = new GlobalPosition(
|
final GlobalPosition position = new GlobalPosition(lodestoneDimensionTag, x, y, z);
|
||||||
lodestoneDimensionTag.getValue(),
|
data.set(StructuredDataKey.LODESTONE_TRACKER, new LodestoneTracker(position, tracked));
|
||||||
xTag != null ? xTag.asInt() : 0,
|
|
||||||
yTag != null ? yTag.asInt() : 0,
|
|
||||||
zTag != null ? zTag.asInt() : 0
|
|
||||||
);
|
|
||||||
data.set(StructuredDataKey.LODESTONE_TRACKER, new LodestoneTracker(position, trackedTag != null && trackedTag.asBoolean()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private FireworkExplosion readExplosion(final CompoundTag tag) {
|
private FireworkExplosion readExplosion(final CompoundTag tag) {
|
||||||
final NumberTag shape = tag.getNumberTag("Type");
|
final int shape = tag.getInt("Type");
|
||||||
final IntArrayTag colors = tag.getIntArrayTag("Colors");
|
final IntArrayTag colors = tag.getIntArrayTag("Colors");
|
||||||
final IntArrayTag fadeColors = tag.getIntArrayTag("FadeColors");
|
final IntArrayTag fadeColors = tag.getIntArrayTag("FadeColors");
|
||||||
final NumberTag trail = tag.getNumberTag("Trail");
|
final boolean trail = tag.getBoolean("Trail");
|
||||||
final NumberTag flicker = tag.getNumberTag("Flicker");
|
final boolean flicker = tag.getBoolean("Flicker");
|
||||||
return new FireworkExplosion(
|
return new FireworkExplosion(
|
||||||
shape != null ? shape.asInt() : 0,
|
shape,
|
||||||
colors != null ? colors.getValue() : new int[0],
|
colors != null ? colors.getValue() : new int[0],
|
||||||
fadeColors != null ? fadeColors.getValue() : new int[0],
|
fadeColors != null ? fadeColors.getValue() : new int[0],
|
||||||
trail != null && trail.asBoolean(),
|
trail,
|
||||||
flicker != null && flicker.asBoolean()
|
flicker
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,17 +648,17 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
pages.add(new FilterableComponent(parsedPage, filtered));
|
pages.add(new FilterableComponent(parsedPage, filtered));
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringTag title = tag.getStringTag("title");
|
final String title = tag.getString("title", "");
|
||||||
final StringTag filteredTitle = tag.getStringTag("filtered_title");
|
final String filteredTitle = tag.getString("filtered_title"); // Nullable
|
||||||
final StringTag author = tag.getStringTag("author");
|
final String author = tag.getString("author", "");
|
||||||
final NumberTag generation = tag.getNumberTag("generation");
|
final int generation = tag.getInt("generation");
|
||||||
final NumberTag resolved = tag.getNumberTag("resolved");
|
final boolean resolved = tag.getBoolean("resolved");
|
||||||
final WrittenBook writtenBook = new WrittenBook(
|
final WrittenBook writtenBook = new WrittenBook(
|
||||||
new FilterableString(title != null ? title.getValue() : "", filteredTitle != null ? filteredTitle.getValue() : null),
|
new FilterableString(title, filteredTitle),
|
||||||
author != null ? author.getValue() : "",
|
author,
|
||||||
generation != null ? generation.asInt() : 0,
|
generation,
|
||||||
pages.toArray(new FilterableComponent[0]),
|
pages.toArray(new FilterableComponent[0]),
|
||||||
resolved != null && resolved.asBoolean()
|
resolved
|
||||||
);
|
);
|
||||||
data.set(StructuredDataKey.WRITTEN_BOOK_CONTENT, writtenBook);
|
data.set(StructuredDataKey.WRITTEN_BOOK_CONTENT, writtenBook);
|
||||||
}
|
}
|
||||||
@ -697,13 +691,13 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
|
|
||||||
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 StringTag id = enchantment.getStringTag("id");
|
final String id = enchantment.getString("id");
|
||||||
final NumberTag lvl = enchantment.getNumberTag("lvl");
|
final NumberTag lvl = enchantment.getNumberTag("lvl");
|
||||||
if (id == null || lvl == null) {
|
if (id == null || lvl == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int intId = Enchantments1_20_3.id(id.getValue());
|
final int intId = Enchantments1_20_3.id(id);
|
||||||
if (intId == -1) {
|
if (intId == -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -725,8 +719,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
data.set(StructuredDataKey.PROFILE, new GameProfile(name, null, EMPTY_PROPERTIES));
|
data.set(StructuredDataKey.PROFILE, new GameProfile(name, null, EMPTY_PROPERTIES));
|
||||||
} else if (skullOwnerTag instanceof CompoundTag) {
|
} else if (skullOwnerTag instanceof CompoundTag) {
|
||||||
final CompoundTag skullOwner = (CompoundTag) skullOwnerTag;
|
final CompoundTag skullOwner = (CompoundTag) skullOwnerTag;
|
||||||
final StringTag nameTag = skullOwner.getStringTag("Name");
|
final String name = skullOwner.getString("Name", "");
|
||||||
final String name = nameTag != null ? nameTag.getValue() : "";
|
|
||||||
|
|
||||||
final IntArrayTag idTag = skullOwner.getIntArrayTag("Id");
|
final IntArrayTag idTag = skullOwner.getIntArrayTag("Id");
|
||||||
UUID uuid = null;
|
UUID uuid = null;
|
||||||
@ -754,14 +747,10 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringTag valueTag = ((CompoundTag) propertyTag).getStringTag("Value");
|
final CompoundTag compoundTag = (CompoundTag) propertyTag;
|
||||||
final StringTag signatureTag = ((CompoundTag) propertyTag).getStringTag("Signature");
|
final String value = compoundTag.getString("Value", "");
|
||||||
final GameProfile.Property property = new GameProfile.Property(
|
final String signature = compoundTag.getString("Signature");
|
||||||
entry.getKey(),
|
properties.add(new GameProfile.Property(entry.getKey(), value, signature));
|
||||||
valueTag != null ? valueTag.getValue() : "",
|
|
||||||
signatureTag != null ? signatureTag.getValue() : null
|
|
||||||
);
|
|
||||||
properties.add(property);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -769,19 +758,17 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
private void updateMapDecorations(final StructuredDataContainer data, final ListTag<CompoundTag> decorationsTag) {
|
private void updateMapDecorations(final StructuredDataContainer data, final ListTag<CompoundTag> decorationsTag) {
|
||||||
final CompoundTag updatedDecorationsTag = new CompoundTag();
|
final CompoundTag updatedDecorationsTag = new CompoundTag();
|
||||||
for (final CompoundTag decorationTag : decorationsTag) {
|
for (final CompoundTag decorationTag : decorationsTag) {
|
||||||
final StringTag idTag = decorationTag.getStringTag("id");
|
final String id = decorationTag.getString("id", "");
|
||||||
final String id = idTag != null ? idTag.asRawString() : "";
|
final int type = decorationTag.getInt("type");
|
||||||
final NumberTag typeTag = decorationTag.getNumberTag("type");
|
final double x = decorationTag.getDouble("x");
|
||||||
final int type = typeTag != null ? typeTag.asInt() : 0;
|
final double z = decorationTag.getDouble("z");
|
||||||
final NumberTag xTag = decorationTag.getNumberTag("x");
|
final float rotation = decorationTag.getFloat("rot");
|
||||||
final NumberTag zTag = decorationTag.getNumberTag("z");
|
|
||||||
final NumberTag rotationTag = decorationTag.getNumberTag("rot");
|
|
||||||
|
|
||||||
final CompoundTag updatedDecorationTag = new CompoundTag();
|
final CompoundTag updatedDecorationTag = new CompoundTag();
|
||||||
updatedDecorationTag.putString("type", MapDecorations1_20_3.mapDecoration(type));
|
updatedDecorationTag.putString("type", MapDecorations1_20_3.idToKey(type));
|
||||||
updatedDecorationTag.putDouble("x", xTag != null ? xTag.asDouble() : 0);
|
updatedDecorationTag.putDouble("x", x);
|
||||||
updatedDecorationTag.putDouble("z", zTag != null ? zTag.asDouble() : 0);
|
updatedDecorationTag.putDouble("z", z);
|
||||||
updatedDecorationTag.putFloat("rotation", rotationTag != null ? rotationTag.asFloat() : 0);
|
updatedDecorationTag.putFloat("rotation", rotation);
|
||||||
updatedDecorationsTag.put(id, updatedDecorationTag);
|
updatedDecorationsTag.put(id, updatedDecorationTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -841,16 +828,42 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Lots of stuff
|
final ListTag<CompoundTag> patternsTag = tag.getListTag("Patterns", CompoundTag.class);
|
||||||
|
if (patternsTag != null) {
|
||||||
|
final BannerPatternLayer[] layers = patternsTag.stream().map(patternTag -> {
|
||||||
|
final String pattern = patternTag.getString("Pattern", "");
|
||||||
|
final int color = patternTag.getInt("Color", -1);
|
||||||
|
final String fullPatternIdentifier = BannerPatterns1_20_3.compactToFullId(pattern);
|
||||||
|
if (fullPatternIdentifier == null || color == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
patternTag.remove("Pattern");
|
||||||
|
patternTag.remove("Color");
|
||||||
|
patternTag.putString("pattern", fullPatternIdentifier);
|
||||||
|
patternTag.putString("color", DyeColors.colorById(color));
|
||||||
|
|
||||||
|
final int id = BannerPatterns1_20_3.keyToId(fullPatternIdentifier);
|
||||||
|
return new BannerPatternLayer(Holder.of(id), color);
|
||||||
|
}).filter(Objects::nonNull).toArray(BannerPatternLayer[]::new);
|
||||||
|
tag.remove("Patterns");
|
||||||
|
tag.put("patterns", patternsTag);
|
||||||
|
|
||||||
|
if (data != null) {
|
||||||
|
data.set(StructuredDataKey.BANNER_PATTERNS, layers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Beehive needed?
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSkullOwnerTag(final CompoundTag tag, final CompoundTag skullOwnerTag) {
|
private void updateSkullOwnerTag(final CompoundTag tag, final CompoundTag skullOwnerTag) {
|
||||||
final CompoundTag profileTag = new CompoundTag();
|
final CompoundTag profileTag = new CompoundTag();
|
||||||
tag.put("profile", profileTag);
|
tag.put("profile", profileTag);
|
||||||
|
|
||||||
final StringTag nameTag = skullOwnerTag.getStringTag("Name");
|
final String name = skullOwnerTag.getString("Name");
|
||||||
if (nameTag != null) {
|
if (name != null) {
|
||||||
profileTag.putString("name", nameTag.getValue());
|
profileTag.putString("name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
final IntArrayTag idTag = skullOwnerTag.getIntArrayTag("Id");
|
final IntArrayTag idTag = skullOwnerTag.getIntArrayTag("Id");
|
||||||
@ -869,20 +882,20 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ListTag<?> value = (ListTag<?>) entry.getValue();
|
final ListTag<?> entryValue = (ListTag<?>) entry.getValue();
|
||||||
for (final Tag propertyTag : value) {
|
for (final Tag propertyTag : entryValue) {
|
||||||
if (!(propertyTag instanceof CompoundTag)) {
|
if (!(propertyTag instanceof CompoundTag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CompoundTag updatedPropertyTag = new CompoundTag();
|
final CompoundTag updatedPropertyTag = new CompoundTag();
|
||||||
final CompoundTag propertyCompoundTag = (CompoundTag) propertyTag;
|
final CompoundTag propertyCompoundTag = (CompoundTag) propertyTag;
|
||||||
final StringTag valueTag = propertyCompoundTag.getStringTag("Value");
|
final String value = propertyCompoundTag.getString("Value", "");
|
||||||
final StringTag signatureTag = propertyCompoundTag.getStringTag("Signature");
|
final String signature = propertyCompoundTag.getString("Signature");
|
||||||
updatedPropertyTag.putString("name", entry.getKey());
|
updatedPropertyTag.putString("name", entry.getKey());
|
||||||
updatedPropertyTag.putString("value", valueTag != null ? valueTag.getValue() : "");
|
updatedPropertyTag.putString("value", value);
|
||||||
if (signatureTag != null) {
|
if (signature != null) {
|
||||||
updatedPropertyTag.putString("signature", signatureTag.getValue());
|
updatedPropertyTag.putString("signature", signature);
|
||||||
}
|
}
|
||||||
propertiesListTag.add(updatedPropertyTag);
|
propertiesListTag.add(updatedPropertyTag);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,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_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_3;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_3;
|
||||||
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 com.viaversion.viaversion.util.Key;
|
||||||
@ -98,6 +99,32 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
|||||||
}
|
}
|
||||||
|
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
|
|
||||||
|
// Send banner patterns and default wolf variant
|
||||||
|
final PacketWrapper wolfVariantsPacket = wrapper.create(ClientboundConfigurationPackets1_20_5.REGISTRY_DATA);
|
||||||
|
wolfVariantsPacket.write(Type.STRING, "minecraft:wolf_variant");
|
||||||
|
final CompoundTag paleWolf = new CompoundTag();
|
||||||
|
paleWolf.putString("texture", "textures/entity/wolf/wolf.png");
|
||||||
|
paleWolf.putString("tame_texture", "textures/entity/wolf/wolf_tame.png");
|
||||||
|
paleWolf.putString("angry_texture", "textures/entity/wolf/wolf_angry.png");
|
||||||
|
paleWolf.put("biomes", new ListTag<>(StringTag.class));
|
||||||
|
wolfVariantsPacket.write(Type.REGISTRY_ENTRY_ARRAY, new RegistryEntry[]{new RegistryEntry("minecraft:pale", paleWolf)});
|
||||||
|
wolfVariantsPacket.send(Protocol1_20_5To1_20_3.class);
|
||||||
|
|
||||||
|
final PacketWrapper bannerPatternsPacket = wrapper.create(ClientboundConfigurationPackets1_20_5.REGISTRY_DATA);
|
||||||
|
bannerPatternsPacket.write(Type.STRING, "minecraft:banner_pattern");
|
||||||
|
final RegistryEntry[] patternEntries = new RegistryEntry[BannerPatterns1_20_3.keys().length];
|
||||||
|
final String[] keys = BannerPatterns1_20_3.keys();
|
||||||
|
for (int i = 0; i < keys.length; i++) {
|
||||||
|
final CompoundTag pattern = new CompoundTag();
|
||||||
|
final String key = keys[i];
|
||||||
|
final String resourceLocation = "minecraft:" + key;
|
||||||
|
pattern.putString("asset_id", key);
|
||||||
|
pattern.putString("translation_key", "block.minecraft.banner." + key);
|
||||||
|
patternEntries[i] = new RegistryEntry(resourceLocation, pattern);
|
||||||
|
}
|
||||||
|
bannerPatternsPacket.write(Type.REGISTRY_ENTRY_ARRAY, patternEntries);
|
||||||
|
bannerPatternsPacket.send(Protocol1_20_5To1_20_3.class);
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_20_3.JOIN_GAME, new PacketHandlers() {
|
protocol.registerClientbound(ClientboundPackets1_20_3.JOIN_GAME, new PacketHandlers() {
|
||||||
@ -202,10 +229,10 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
|||||||
});
|
});
|
||||||
|
|
||||||
registerMetaTypeHandler(
|
registerMetaTypeHandler(
|
||||||
Types1_20_5.META_TYPES.itemType,
|
Types1_20_5.META_TYPES.itemType,
|
||||||
Types1_20_5.META_TYPES.blockStateType,
|
Types1_20_5.META_TYPES.blockStateType,
|
||||||
Types1_20_5.META_TYPES.optionalBlockStateType,
|
Types1_20_5.META_TYPES.optionalBlockStateType,
|
||||||
Types1_20_5.META_TYPES.particleType
|
Types1_20_5.META_TYPES.particleType
|
||||||
);
|
);
|
||||||
|
|
||||||
filter().type(EntityTypes1_20_5.LLAMA).removeIndex(20); // Carpet color
|
filter().type(EntityTypes1_20_5.LLAMA).removeIndex(20); // Carpet color
|
||||||
|
@ -45,6 +45,10 @@ public final class KeyMappings {
|
|||||||
return keyToId.getInt(Key.stripMinecraftNamespace(identifier));
|
return keyToId.getInt(Key.stripMinecraftNamespace(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] keys() {
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return keys.length;
|
return keys.length;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ metadata.format.version = "1.1"
|
|||||||
|
|
||||||
gson = "2.10.1"
|
gson = "2.10.1"
|
||||||
fastutil = "8.5.12"
|
fastutil = "8.5.12"
|
||||||
vianbt = "4.4.2"
|
vianbt = "4.4.3"
|
||||||
mcstructs = "2.4.2"
|
mcstructs = "2.4.2"
|
||||||
|
|
||||||
# Common provided
|
# Common provided
|
||||||
|
Loading…
Reference in New Issue
Block a user