Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-20 06:50:08 +01:00
WIP 24w21b
Dieser Commit ist enthalten in:
Ursprung
832dbdf493
Commit
134c3559bf
@ -106,9 +106,19 @@ public final class StructuredDataContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T> void replaceKey(final StructuredDataKey<T> key, final StructuredDataKey<T> toKey) {
|
public <T> void replaceKey(final StructuredDataKey<T> key, final StructuredDataKey<T> toKey) {
|
||||||
|
replace(key, toKey, Function.identity());
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T, V> void replace(final StructuredDataKey<T> key, final StructuredDataKey<V> toKey, final Function<T, V> valueMapper) {
|
||||||
final StructuredData<T> data = remove(key);
|
final StructuredData<T> data = remove(key);
|
||||||
if (data != null) {
|
if (data == null) {
|
||||||
set(toKey, data.value());
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.isPresent()) {
|
||||||
|
set(toKey, valueMapper.apply(data.value()));
|
||||||
|
} else {
|
||||||
|
addEmpty(toKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ import com.viaversion.viaversion.api.minecraft.Holder;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
|
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrim;
|
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrim;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers;
|
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_20_5;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_21;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
|
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
|
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.BlockStateProperties;
|
import com.viaversion.viaversion.api.minecraft.item.data.BlockStateProperties;
|
||||||
@ -40,6 +41,7 @@ import com.viaversion.viaversion.api.minecraft.item.data.FireworkExplosion;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.data.Fireworks;
|
import com.viaversion.viaversion.api.minecraft.item.data.Fireworks;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties;
|
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.Instrument;
|
import com.viaversion.viaversion.api.minecraft.item.data.Instrument;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.item.data.JukeboxPlayable;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.LodestoneTracker;
|
import com.viaversion.viaversion.api.minecraft.item.data.LodestoneTracker;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.PotDecorations;
|
import com.viaversion.viaversion.api.minecraft.item.data.PotDecorations;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.PotionContents;
|
import com.viaversion.viaversion.api.minecraft.item.data.PotionContents;
|
||||||
@ -66,7 +68,8 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
|
|||||||
public static final StructuredDataKey<Enchantments> ENCHANTMENTS = new StructuredDataKey<>("enchantments", Enchantments.TYPE);
|
public static final StructuredDataKey<Enchantments> ENCHANTMENTS = new StructuredDataKey<>("enchantments", Enchantments.TYPE);
|
||||||
public static final StructuredDataKey<AdventureModePredicate> CAN_PLACE_ON = new StructuredDataKey<>("can_place_on", AdventureModePredicate.TYPE);
|
public static final StructuredDataKey<AdventureModePredicate> CAN_PLACE_ON = new StructuredDataKey<>("can_place_on", AdventureModePredicate.TYPE);
|
||||||
public static final StructuredDataKey<AdventureModePredicate> CAN_BREAK = new StructuredDataKey<>("can_break", AdventureModePredicate.TYPE);
|
public static final StructuredDataKey<AdventureModePredicate> CAN_BREAK = new StructuredDataKey<>("can_break", AdventureModePredicate.TYPE);
|
||||||
public static final StructuredDataKey<AttributeModifiers> ATTRIBUTE_MODIFIERS = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers.TYPE);
|
public static final StructuredDataKey<AttributeModifiers1_20_5> ATTRIBUTE_MODIFIERS1_20_5 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_20_5.TYPE);
|
||||||
|
public static final StructuredDataKey<AttributeModifiers1_21> ATTRIBUTE_MODIFIERS1_21 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_21.TYPE);
|
||||||
public static final StructuredDataKey<Integer> CUSTOM_MODEL_DATA = new StructuredDataKey<>("custom_model_data", Types.VAR_INT);
|
public static final StructuredDataKey<Integer> CUSTOM_MODEL_DATA = new StructuredDataKey<>("custom_model_data", Types.VAR_INT);
|
||||||
public static final StructuredDataKey<Unit> HIDE_ADDITIONAL_TOOLTIP = new StructuredDataKey<>("hide_additional_tooltip", Types.EMPTY);
|
public static final StructuredDataKey<Unit> HIDE_ADDITIONAL_TOOLTIP = new StructuredDataKey<>("hide_additional_tooltip", Types.EMPTY);
|
||||||
public static final StructuredDataKey<Unit> HIDE_TOOLTIP = new StructuredDataKey<>("hide_tooltip", Types.EMPTY);
|
public static final StructuredDataKey<Unit> HIDE_TOOLTIP = new StructuredDataKey<>("hide_tooltip", Types.EMPTY);
|
||||||
@ -97,6 +100,7 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
|
|||||||
public static final StructuredDataKey<CompoundTag> BLOCK_ENTITY_DATA = new StructuredDataKey<>("block_entity_data", Types.COMPOUND_TAG);
|
public static final StructuredDataKey<CompoundTag> BLOCK_ENTITY_DATA = new StructuredDataKey<>("block_entity_data", Types.COMPOUND_TAG);
|
||||||
public static final StructuredDataKey<Holder<Instrument>> INSTRUMENT = new StructuredDataKey<>("instrument", Instrument.TYPE);
|
public static final StructuredDataKey<Holder<Instrument>> INSTRUMENT = new StructuredDataKey<>("instrument", Instrument.TYPE);
|
||||||
public static final StructuredDataKey<Integer> OMINOUS_BOTTLE_AMPLIFIER = new StructuredDataKey<>("ominous_bottle_amplifier", Types.VAR_INT);
|
public static final StructuredDataKey<Integer> OMINOUS_BOTTLE_AMPLIFIER = new StructuredDataKey<>("ominous_bottle_amplifier", Types.VAR_INT);
|
||||||
|
public static final StructuredDataKey<JukeboxPlayable> JUKEBOX_PLAYABLE = new StructuredDataKey<>("jukebox_playable", JukeboxPlayable.TYPE);
|
||||||
public static final StructuredDataKey<Tag> RECIPES = new StructuredDataKey<>("recipes", Types.TAG);
|
public static final StructuredDataKey<Tag> RECIPES = new StructuredDataKey<>("recipes", Types.TAG);
|
||||||
public static final StructuredDataKey<LodestoneTracker> LODESTONE_TRACKER = new StructuredDataKey<>("lodestone_tracker", LodestoneTracker.TYPE);
|
public static final StructuredDataKey<LodestoneTracker> LODESTONE_TRACKER = new StructuredDataKey<>("lodestone_tracker", LodestoneTracker.TYPE);
|
||||||
public static final StructuredDataKey<FireworkExplosion> FIREWORK_EXPLOSION = new StructuredDataKey<>("firework_explosion", FireworkExplosion.TYPE);
|
public static final StructuredDataKey<FireworkExplosion> FIREWORK_EXPLOSION = new StructuredDataKey<>("firework_explosion", FireworkExplosion.TYPE);
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
|
||||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
|
||||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
|
|
||||||
public record AttributeModifier(int attribute, ModifierData modifier, int slotType) {
|
|
||||||
|
|
||||||
public static final Type<AttributeModifier> TYPE = new Type<>(AttributeModifier.class) {
|
|
||||||
@Override
|
|
||||||
public AttributeModifier read(final ByteBuf buffer) {
|
|
||||||
final int attribute = Types.VAR_INT.readPrimitive(buffer);
|
|
||||||
final ModifierData modifier = ModifierData.TYPE.read(buffer);
|
|
||||||
final int slot = Types.VAR_INT.readPrimitive(buffer);
|
|
||||||
return new AttributeModifier(attribute, modifier, slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(final ByteBuf buffer, final AttributeModifier value) {
|
|
||||||
Types.VAR_INT.writePrimitive(buffer, value.attribute);
|
|
||||||
ModifierData.TYPE.write(buffer, value.modifier);
|
|
||||||
Types.VAR_INT.writePrimitive(buffer, value.slotType);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
public static final Type<AttributeModifier[]> ARRAY_TYPE = new ArrayType<>(TYPE);
|
|
||||||
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
|
||||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
|
|
||||||
public record AttributeModifiers(AttributeModifier[] modifiers, boolean showInTooltip) {
|
|
||||||
|
|
||||||
public static final Type<AttributeModifiers> TYPE = new Type<>(AttributeModifiers.class) {
|
|
||||||
@Override
|
|
||||||
public AttributeModifiers read(final ByteBuf buffer) {
|
|
||||||
final AttributeModifier[] modifiers = AttributeModifier.ARRAY_TYPE.read(buffer);
|
|
||||||
final boolean showInTooltip = buffer.readBoolean();
|
|
||||||
return new AttributeModifiers(modifiers, showInTooltip);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(final ByteBuf buffer, final AttributeModifiers value) {
|
|
||||||
AttributeModifier.ARRAY_TYPE.write(buffer, value.modifiers());
|
|
||||||
buffer.writeBoolean(value.showInTooltip());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||||
|
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
|
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public record AttributeModifiers1_20_5(AttributeModifier[] modifiers, boolean showInTooltip) {
|
||||||
|
|
||||||
|
public static final Type<AttributeModifiers1_20_5> TYPE = new Type<>(AttributeModifiers1_20_5.class) {
|
||||||
|
@Override
|
||||||
|
public AttributeModifiers1_20_5 read(final ByteBuf buffer) {
|
||||||
|
final AttributeModifier[] modifiers = AttributeModifier.ARRAY_TYPE.read(buffer);
|
||||||
|
final boolean showInTooltip = buffer.readBoolean();
|
||||||
|
return new AttributeModifiers1_20_5(modifiers, showInTooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(final ByteBuf buffer, final AttributeModifiers1_20_5 value) {
|
||||||
|
AttributeModifier.ARRAY_TYPE.write(buffer, value.modifiers());
|
||||||
|
buffer.writeBoolean(value.showInTooltip());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public record AttributeModifier(int attribute, ModifierData modifier, int slotType) {
|
||||||
|
|
||||||
|
public static final Type<AttributeModifier> TYPE = new Type<>(AttributeModifier.class) {
|
||||||
|
@Override
|
||||||
|
public AttributeModifier read(final ByteBuf buffer) {
|
||||||
|
final int attribute = Types.VAR_INT.readPrimitive(buffer);
|
||||||
|
final ModifierData modifier = ModifierData.TYPE.read(buffer);
|
||||||
|
final int slot = Types.VAR_INT.readPrimitive(buffer);
|
||||||
|
return new AttributeModifier(attribute, modifier, slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(final ByteBuf buffer, final AttributeModifier value) {
|
||||||
|
Types.VAR_INT.writePrimitive(buffer, value.attribute);
|
||||||
|
ModifierData.TYPE.write(buffer, value.modifier);
|
||||||
|
Types.VAR_INT.writePrimitive(buffer, value.slotType);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
public static final Type<AttributeModifier[]> ARRAY_TYPE = new ArrayType<>(TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public record ModifierData(UUID uuid, String name, double amount, int operation) {
|
||||||
|
|
||||||
|
public static final Type<ModifierData> TYPE = new Type<>(ModifierData.class) {
|
||||||
|
@Override
|
||||||
|
public ModifierData read(final ByteBuf buffer) {
|
||||||
|
final UUID uuid = Types.UUID.read(buffer);
|
||||||
|
final String name = Types.STRING.read(buffer);
|
||||||
|
final double amount = buffer.readDouble();
|
||||||
|
final int operation = Types.VAR_INT.readPrimitive(buffer);
|
||||||
|
return new ModifierData(uuid, name, amount, operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(final ByteBuf buffer, final ModifierData value) {
|
||||||
|
Types.UUID.write(buffer, value.uuid);
|
||||||
|
Types.STRING.write(buffer, value.name);
|
||||||
|
buffer.writeDouble(value.amount);
|
||||||
|
Types.VAR_INT.writePrimitive(buffer, value.operation);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||||
|
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
|
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
public record AttributeModifiers1_21(AttributeModifier[] modifiers, boolean showInTooltip) {
|
||||||
|
|
||||||
|
public static final Type<AttributeModifiers1_21> TYPE = new Type<>(AttributeModifiers1_21.class) {
|
||||||
|
@Override
|
||||||
|
public AttributeModifiers1_21 read(final ByteBuf buffer) {
|
||||||
|
final AttributeModifier[] modifiers = AttributeModifier.ARRAY_TYPE.read(buffer);
|
||||||
|
final boolean showInTooltip = buffer.readBoolean();
|
||||||
|
return new AttributeModifiers1_21(modifiers, showInTooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(final ByteBuf buffer, final AttributeModifiers1_21 value) {
|
||||||
|
AttributeModifier.ARRAY_TYPE.write(buffer, value.modifiers());
|
||||||
|
buffer.writeBoolean(value.showInTooltip());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public record AttributeModifier(int attribute, ModifierData modifier, int slotType) {
|
||||||
|
|
||||||
|
public static final Type<AttributeModifier> TYPE = new Type<>(AttributeModifier.class) {
|
||||||
|
@Override
|
||||||
|
public AttributeModifier read(final ByteBuf buffer) {
|
||||||
|
final int attribute = Types.VAR_INT.readPrimitive(buffer);
|
||||||
|
final ModifierData modifier = ModifierData.TYPE.read(buffer);
|
||||||
|
final int slot = Types.VAR_INT.readPrimitive(buffer);
|
||||||
|
return new AttributeModifier(attribute, modifier, slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(final ByteBuf buffer, final AttributeModifier value) {
|
||||||
|
Types.VAR_INT.writePrimitive(buffer, value.attribute);
|
||||||
|
ModifierData.TYPE.write(buffer, value.modifier);
|
||||||
|
Types.VAR_INT.writePrimitive(buffer, value.slotType);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
public static final Type<AttributeModifier[]> ARRAY_TYPE = new ArrayType<>(TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public record ModifierData(String id, double amount, int operation) {
|
||||||
|
|
||||||
|
public static final Type<ModifierData> TYPE = new Type<>(ModifierData.class) {
|
||||||
|
@Override
|
||||||
|
public ModifierData read(final ByteBuf buffer) {
|
||||||
|
final String id = Types.STRING.read(buffer);
|
||||||
|
final double amount = buffer.readDouble();
|
||||||
|
final int operation = Types.VAR_INT.readPrimitive(buffer);
|
||||||
|
return new ModifierData(id, amount, operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(final ByteBuf buffer, final ModifierData value) {
|
||||||
|
Types.STRING.write(buffer, value.id);
|
||||||
|
buffer.writeDouble(value.amount);
|
||||||
|
Types.VAR_INT.writePrimitive(buffer, value.operation);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||||
|
* Copyright (C) 2016-2024 ViaVersion and contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.viaversion.viaversion.api.minecraft.item.data;
|
||||||
|
|
||||||
|
import com.viaversion.nbt.tag.Tag;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.SoundEvent;
|
||||||
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
|
import com.viaversion.viaversion.api.type.types.misc.HolderType;
|
||||||
|
import com.viaversion.viaversion.util.Either;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
public record JukeboxPlayable(Either<Holder<JukeboxSong>, String> song, boolean showInTooltip) {
|
||||||
|
|
||||||
|
public static final Type<JukeboxPlayable> TYPE = new Type<>(JukeboxPlayable.class) {
|
||||||
|
@Override
|
||||||
|
public JukeboxPlayable read(final ByteBuf buffer) {
|
||||||
|
final Either<Holder<JukeboxSong>, String> position = Type.readEither(buffer, JukeboxSong.TYPE, Types.STRING);
|
||||||
|
final boolean showInTooltip = buffer.readBoolean();
|
||||||
|
return new JukeboxPlayable(position, showInTooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(final ByteBuf buffer, final JukeboxPlayable value) {
|
||||||
|
Type.writeEither(buffer, value.song, JukeboxSong.TYPE, Types.STRING);
|
||||||
|
buffer.writeBoolean(value.showInTooltip);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public record JukeboxSong(Holder<SoundEvent> soundEvent, Tag description,
|
||||||
|
float lengthInSeconds, int comparatorOutput) {
|
||||||
|
|
||||||
|
public static final HolderType<JukeboxSong> TYPE = new HolderType<>() {
|
||||||
|
@Override
|
||||||
|
public JukeboxSong readDirect(final ByteBuf buffer) {
|
||||||
|
final Holder<SoundEvent> soundEvent = Types.SOUND_EVENT.read(buffer);
|
||||||
|
final Tag description = Types.TAG.read(buffer);
|
||||||
|
final float lengthInSeconds = buffer.readFloat();
|
||||||
|
final int useDuration = Types.VAR_INT.readPrimitive(buffer);
|
||||||
|
return new JukeboxSong(soundEvent, description, lengthInSeconds, useDuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeDirect(final ByteBuf buffer, final JukeboxSong value) {
|
||||||
|
Types.SOUND_EVENT.write(buffer, value.soundEvent);
|
||||||
|
Types.TAG.write(buffer, value.description);
|
||||||
|
buffer.writeFloat(value.lengthInSeconds);
|
||||||
|
Types.VAR_INT.writePrimitive(buffer, value.comparatorOutput);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
|
||||||
* Copyright (C) 2016-2024 ViaVersion and contributors
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all
|
|
||||||
* copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
* SOFTWARE.
|
|
||||||
*/
|
|
||||||
package com.viaversion.viaversion.api.minecraft.item.data;
|
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public record ModifierData(UUID uuid, String name, double amount, int operation) {
|
|
||||||
|
|
||||||
public static final Type<ModifierData> TYPE = new Type<>(ModifierData.class) {
|
|
||||||
@Override
|
|
||||||
public ModifierData read(final ByteBuf buffer) {
|
|
||||||
final UUID uuid = Types.UUID.read(buffer);
|
|
||||||
final String name = Types.STRING.read(buffer);
|
|
||||||
final double amount = buffer.readDouble();
|
|
||||||
final int operation = Types.VAR_INT.readPrimitive(buffer);
|
|
||||||
return new ModifierData(uuid, name, amount, operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(final ByteBuf buffer, final ModifierData value) {
|
|
||||||
Types.UUID.write(buffer, value.uuid);
|
|
||||||
Types.STRING.write(buffer, value.name);
|
|
||||||
buffer.writeDouble(value.amount);
|
|
||||||
Types.VAR_INT.writePrimitive(buffer, value.operation);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
@ -31,7 +31,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
|
|
||||||
public record StatePropertyMatcher(String name, Either<String, RangedMatcher> matcher) {
|
public record StatePropertyMatcher(String name, Either<String, RangedMatcher> matcher) {
|
||||||
|
|
||||||
// TODO Abstract Either reading
|
|
||||||
public static final Type<StatePropertyMatcher> TYPE = new Type<>(StatePropertyMatcher.class) {
|
public static final Type<StatePropertyMatcher> TYPE = new Type<>(StatePropertyMatcher.class) {
|
||||||
@Override
|
@Override
|
||||||
public StatePropertyMatcher read(final ByteBuf buffer) {
|
public StatePropertyMatcher read(final ByteBuf buffer) {
|
||||||
|
@ -84,7 +84,7 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
|
|||||||
public static final ProtocolVersion v1_20_2 = register(764, "1.20.2");
|
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_3 = register(765, "1.20.3-1.20.4", new SubVersionRange("1.20", 3, 4));
|
||||||
public static final ProtocolVersion v1_20_5 = register(766, "1.20.5-1.20.6", new SubVersionRange("1.20", 5, 6));
|
public static final ProtocolVersion v1_20_5 = register(766, "1.20.5-1.20.6", new SubVersionRange("1.20", 5, 6));
|
||||||
public static final ProtocolVersion v1_21 = register(767, 196, "1.21");
|
public static final ProtocolVersion v1_21 = register(767, 198, "1.21");
|
||||||
public static final ProtocolVersion unknown = new ProtocolVersion(VersionType.SPECIAL, -1, -1, "UNKNOWN", null);
|
public static final ProtocolVersion unknown = new ProtocolVersion(VersionType.SPECIAL, -1, -1, "UNKNOWN", null);
|
||||||
|
|
||||||
public static ProtocolVersion register(int version, String name) {
|
public static ProtocolVersion register(int version, String name) {
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.type;
|
package com.viaversion.viaversion.api.type;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.util.Either;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type for buffer reading and writing.
|
* Type for buffer reading and writing.
|
||||||
*
|
*
|
||||||
@ -75,4 +78,22 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return getTypeName();
|
return getTypeName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <X, Y> Either<X, Y> readEither(final ByteBuf buf, final Type<X> leftType, final Type<Y> rightType) {
|
||||||
|
if (buf.readBoolean()) {
|
||||||
|
return Either.left(leftType.read(buf));
|
||||||
|
} else {
|
||||||
|
return Either.right(rightType.read(buf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <X, Y> void writeEither(final ByteBuf buf, final Either<X, Y> value, final Type<X> leftType, final Type<Y> rightType) {
|
||||||
|
if (value.isLeft()) {
|
||||||
|
buf.writeBoolean(true);
|
||||||
|
leftType.write(buf, value.left());
|
||||||
|
} else {
|
||||||
|
buf.writeBoolean(false);
|
||||||
|
rightType.write(buf, value.right());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ public final class Protocol1_20_3To1_20_5 extends AbstractProtocol<ClientboundPa
|
|||||||
.add(StructuredDataKey.DAMAGE).add(StructuredDataKey.UNBREAKABLE).add(StructuredDataKey.RARITY)
|
.add(StructuredDataKey.DAMAGE).add(StructuredDataKey.UNBREAKABLE).add(StructuredDataKey.RARITY)
|
||||||
.add(StructuredDataKey.HIDE_TOOLTIP).add(StructuredDataKey.FOOD1_20_5).add(StructuredDataKey.FIRE_RESISTANT)
|
.add(StructuredDataKey.HIDE_TOOLTIP).add(StructuredDataKey.FOOD1_20_5).add(StructuredDataKey.FIRE_RESISTANT)
|
||||||
.add(StructuredDataKey.CUSTOM_NAME).add(StructuredDataKey.LORE).add(StructuredDataKey.ENCHANTMENTS)
|
.add(StructuredDataKey.CUSTOM_NAME).add(StructuredDataKey.LORE).add(StructuredDataKey.ENCHANTMENTS)
|
||||||
.add(StructuredDataKey.CAN_PLACE_ON).add(StructuredDataKey.CAN_BREAK).add(StructuredDataKey.ATTRIBUTE_MODIFIERS)
|
.add(StructuredDataKey.CAN_PLACE_ON).add(StructuredDataKey.CAN_BREAK).add(StructuredDataKey.ATTRIBUTE_MODIFIERS1_20_5)
|
||||||
.add(StructuredDataKey.CUSTOM_MODEL_DATA).add(StructuredDataKey.HIDE_ADDITIONAL_TOOLTIP).add(StructuredDataKey.REPAIR_COST)
|
.add(StructuredDataKey.CUSTOM_MODEL_DATA).add(StructuredDataKey.HIDE_ADDITIONAL_TOOLTIP).add(StructuredDataKey.REPAIR_COST)
|
||||||
.add(StructuredDataKey.CREATIVE_SLOT_LOCK).add(StructuredDataKey.ENCHANTMENT_GLINT_OVERRIDE).add(StructuredDataKey.INTANGIBLE_PROJECTILE)
|
.add(StructuredDataKey.CREATIVE_SLOT_LOCK).add(StructuredDataKey.ENCHANTMENT_GLINT_OVERRIDE).add(StructuredDataKey.INTANGIBLE_PROJECTILE)
|
||||||
.add(StructuredDataKey.STORED_ENCHANTMENTS).add(StructuredDataKey.DYED_COLOR).add(StructuredDataKey.MAP_COLOR)
|
.add(StructuredDataKey.STORED_ENCHANTMENTS).add(StructuredDataKey.DYED_COLOR).add(StructuredDataKey.MAP_COLOR)
|
||||||
|
@ -47,8 +47,9 @@ import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrim;
|
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrim;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrimMaterial;
|
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.AttributeModifiers1_20_5;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers;
|
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_20_5.AttributeModifier;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_20_5.ModifierData;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.BannerPattern;
|
import com.viaversion.viaversion.api.minecraft.item.data.BannerPattern;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
|
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
|
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
|
||||||
@ -64,7 +65,6 @@ import com.viaversion.viaversion.api.minecraft.item.data.FoodEffect;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties;
|
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.Instrument;
|
import com.viaversion.viaversion.api.minecraft.item.data.Instrument;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.LodestoneTracker;
|
import com.viaversion.viaversion.api.minecraft.item.data.LodestoneTracker;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.ModifierData;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.PotDecorations;
|
import com.viaversion.viaversion.api.minecraft.item.data.PotDecorations;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.PotionContents;
|
import com.viaversion.viaversion.api.minecraft.item.data.PotionContents;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.PotionEffect;
|
import com.viaversion.viaversion.api.minecraft.item.data.PotionEffect;
|
||||||
@ -515,7 +515,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
if (attributeModifiersTag != null) {
|
if (attributeModifiersTag != null) {
|
||||||
updateAttributes(data, attributeModifiersTag, showAttributes);
|
updateAttributes(data, attributeModifiersTag, showAttributes);
|
||||||
} else if (!showAttributes) {
|
} else if (!showAttributes) {
|
||||||
data.set(StructuredDataKey.ATTRIBUTE_MODIFIERS, new AttributeModifiers(new AttributeModifier[0], false));
|
data.set(StructuredDataKey.ATTRIBUTE_MODIFIERS1_20_5, new AttributeModifiers1_20_5(new AttributeModifier[0], false));
|
||||||
}
|
}
|
||||||
|
|
||||||
final CompoundTag fireworksTag = tag.getCompoundTag("Fireworks");
|
final CompoundTag fireworksTag = tag.getCompoundTag("Fireworks");
|
||||||
@ -874,7 +874,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
slotTypeId
|
slotTypeId
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
data.set(StructuredDataKey.ATTRIBUTE_MODIFIERS, new AttributeModifiers(modifiers.toArray(new AttributeModifier[0]), showInTooltip));
|
data.set(StructuredDataKey.ATTRIBUTE_MODIFIERS1_20_5, new AttributeModifiers1_20_5(modifiers.toArray(new AttributeModifier[0]), showInTooltip));
|
||||||
}
|
}
|
||||||
|
|
||||||
private PotionEffectData readPotionEffectData(final CompoundTag tag) {
|
private PotionEffectData readPotionEffectData(final CompoundTag tag) {
|
||||||
|
@ -41,8 +41,9 @@ import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrim;
|
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrim;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrimMaterial;
|
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.AttributeModifiers1_20_5;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers;
|
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_20_5.AttributeModifier;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_20_5.ModifierData;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.BannerPattern;
|
import com.viaversion.viaversion.api.minecraft.item.data.BannerPattern;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
|
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
|
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
|
||||||
@ -58,7 +59,6 @@ import com.viaversion.viaversion.api.minecraft.item.data.FoodEffect;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties;
|
import com.viaversion.viaversion.api.minecraft.item.data.FoodProperties;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.Instrument;
|
import com.viaversion.viaversion.api.minecraft.item.data.Instrument;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.LodestoneTracker;
|
import com.viaversion.viaversion.api.minecraft.item.data.LodestoneTracker;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.ModifierData;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.PotDecorations;
|
import com.viaversion.viaversion.api.minecraft.item.data.PotDecorations;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.PotionContents;
|
import com.viaversion.viaversion.api.minecraft.item.data.PotionContents;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.PotionEffect;
|
import com.viaversion.viaversion.api.minecraft.item.data.PotionEffect;
|
||||||
@ -126,7 +126,7 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Co
|
|||||||
register(StructuredDataKey.ENCHANTMENTS, this::convertEnchantments);
|
register(StructuredDataKey.ENCHANTMENTS, this::convertEnchantments);
|
||||||
register(StructuredDataKey.CAN_PLACE_ON, this::convertCanPlaceOn);
|
register(StructuredDataKey.CAN_PLACE_ON, this::convertCanPlaceOn);
|
||||||
register(StructuredDataKey.CAN_BREAK, this::convertCanBreak);
|
register(StructuredDataKey.CAN_BREAK, this::convertCanBreak);
|
||||||
register(StructuredDataKey.ATTRIBUTE_MODIFIERS, this::convertAttributeModifiers);
|
register(StructuredDataKey.ATTRIBUTE_MODIFIERS1_20_5, this::convertAttributeModifiers);
|
||||||
register(StructuredDataKey.CUSTOM_MODEL_DATA, this::convertCustomModelData);
|
register(StructuredDataKey.CUSTOM_MODEL_DATA, this::convertCustomModelData);
|
||||||
register(StructuredDataKey.HIDE_ADDITIONAL_TOOLTIP, this::convertHideAdditionalTooltip);
|
register(StructuredDataKey.HIDE_ADDITIONAL_TOOLTIP, this::convertHideAdditionalTooltip);
|
||||||
register(StructuredDataKey.HIDE_TOOLTIP, this::convertHideTooltip);
|
register(StructuredDataKey.HIDE_TOOLTIP, this::convertHideTooltip);
|
||||||
@ -446,7 +446,7 @@ public class ComponentRewriter1_20_5<C extends ClientboundPacketType> extends Co
|
|||||||
return convertCanPlaceOn(value);
|
return convertCanPlaceOn(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CompoundTag convertAttributeModifiers(final AttributeModifiers value) {
|
protected CompoundTag convertAttributeModifiers(final AttributeModifiers1_20_5 value) {
|
||||||
final CompoundTag tag = new CompoundTag();
|
final CompoundTag tag = new CompoundTag();
|
||||||
final ListTag<CompoundTag> modifiers = new ListTag<>(CompoundTag.class);
|
final ListTag<CompoundTag> modifiers = new ListTag<>(CompoundTag.class);
|
||||||
for (final AttributeModifier modifier : value.modifiers()) {
|
for (final AttributeModifier modifier : value.modifiers()) {
|
||||||
|
@ -35,7 +35,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
|
import com.viaversion.viaversion.api.minecraft.item.data.AdventureModePredicate;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.ArmorTrimMaterial;
|
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.AttributeModifiers1_20_5.AttributeModifier;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.BannerPattern;
|
import com.viaversion.viaversion.api.minecraft.item.data.BannerPattern;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
|
import com.viaversion.viaversion.api.minecraft.item.data.BannerPatternLayer;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
|
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
|
||||||
@ -128,7 +128,7 @@ public final class StructuredDataConverter {
|
|||||||
});
|
});
|
||||||
register(StructuredDataKey.ENCHANTMENTS, (data, tag) -> convertEnchantments(data, tag, false));
|
register(StructuredDataKey.ENCHANTMENTS, (data, tag) -> convertEnchantments(data, tag, false));
|
||||||
register(StructuredDataKey.STORED_ENCHANTMENTS, (data, tag) -> convertEnchantments(data, tag, true));
|
register(StructuredDataKey.STORED_ENCHANTMENTS, (data, tag) -> convertEnchantments(data, tag, true));
|
||||||
register(StructuredDataKey.ATTRIBUTE_MODIFIERS, (data, tag) -> {
|
register(StructuredDataKey.ATTRIBUTE_MODIFIERS1_20_5, (data, tag) -> {
|
||||||
final ListTag<CompoundTag> modifiers = new ListTag<>(CompoundTag.class);
|
final ListTag<CompoundTag> modifiers = new ListTag<>(CompoundTag.class);
|
||||||
for (int i = 0; i < data.modifiers().length; i++) {
|
for (int i = 0; i < data.modifiers().length; i++) {
|
||||||
final AttributeModifier modifier = data.modifiers()[i];
|
final AttributeModifier modifier = data.modifiers()[i];
|
||||||
|
@ -27,23 +27,28 @@ import com.viaversion.viaversion.api.type.Types;
|
|||||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_21;
|
import com.viaversion.viaversion.api.type.types.version.Types1_21;
|
||||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.data.MappingData;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.EntityPacketRewriter1_21;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundConfigurationPackets1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundConfigurationPackets1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundConfigurationPackets1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundConfigurationPackets1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
||||||
import com.viaversion.viaversion.rewriter.AttributeRewriter;
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.data.AttributeModifierMappings1_21;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.data.MappingData;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.EntityPacketRewriter1_21;
|
||||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
|
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
|
||||||
|
|
||||||
public final class Protocol1_20_5To1_21 extends AbstractProtocol<ClientboundPacket1_20_5, ClientboundPacket1_20_5, ServerboundPacket1_20_5, ServerboundPacket1_20_5> {
|
public final class Protocol1_20_5To1_21 extends AbstractProtocol<ClientboundPacket1_20_5, ClientboundPacket1_21, ServerboundPacket1_20_5, ServerboundPacket1_20_5> {
|
||||||
|
|
||||||
public static final MappingData MAPPINGS = new MappingData();
|
public static final MappingData MAPPINGS = new MappingData();
|
||||||
private final EntityPacketRewriter1_21 entityRewriter = new EntityPacketRewriter1_21(this);
|
private final EntityPacketRewriter1_21 entityRewriter = new EntityPacketRewriter1_21(this);
|
||||||
@ -51,7 +56,7 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol<ClientboundPack
|
|||||||
private final TagRewriter<ClientboundPacket1_20_5> tagRewriter = new TagRewriter<>(this);
|
private final TagRewriter<ClientboundPacket1_20_5> tagRewriter = new TagRewriter<>(this);
|
||||||
|
|
||||||
public Protocol1_20_5To1_21() {
|
public Protocol1_20_5To1_21() {
|
||||||
super(ClientboundPacket1_20_5.class, ClientboundPacket1_20_5.class, ServerboundPacket1_20_5.class, ServerboundPacket1_20_5.class);
|
super(ClientboundPacket1_20_5.class, ClientboundPacket1_21.class, ServerboundPacket1_20_5.class, ServerboundPacket1_20_5.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,7 +71,24 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol<ClientboundPack
|
|||||||
soundRewriter.registerSound1_19_3(ClientboundPackets1_20_5.SOUND_ENTITY);
|
soundRewriter.registerSound1_19_3(ClientboundPackets1_20_5.SOUND_ENTITY);
|
||||||
|
|
||||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_5.AWARD_STATS);
|
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_5.AWARD_STATS);
|
||||||
new AttributeRewriter<>(this).register1_20_5(ClientboundPackets1_20_5.UPDATE_ATTRIBUTES);
|
|
||||||
|
registerClientbound(ClientboundPackets1_20_5.UPDATE_ATTRIBUTES, wrapper -> {
|
||||||
|
wrapper.passthrough(Types.VAR_INT); // Entity ID
|
||||||
|
|
||||||
|
final int size = wrapper.passthrough(Types.VAR_INT);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
final int attributeId = wrapper.read(Types.VAR_INT);
|
||||||
|
wrapper.write(Types.VAR_INT, MAPPINGS.getNewAttributeId(attributeId));
|
||||||
|
wrapper.passthrough(Types.DOUBLE); // Base
|
||||||
|
final int modifierSize = wrapper.passthrough(Types.VAR_INT);
|
||||||
|
for (int j = 0; j < modifierSize; j++) {
|
||||||
|
final UUID uuid = wrapper.read(Types.UUID);
|
||||||
|
wrapper.write(Types.STRING, mapAttributeUUID(uuid, null));
|
||||||
|
wrapper.passthrough(Types.DOUBLE); // Amount
|
||||||
|
wrapper.passthrough(Types.BYTE); // Operation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_20_5.PROJECTILE_POWER, wrapper -> {
|
registerClientbound(ClientboundPackets1_20_5.PROJECTILE_POWER, wrapper -> {
|
||||||
wrapper.passthrough(Types.VAR_INT); // Id
|
wrapper.passthrough(Types.VAR_INT); // Id
|
||||||
@ -78,6 +100,22 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol<ClientboundPack
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String mapAttributeUUID(final UUID uuid, final String name) {
|
||||||
|
String id = AttributeModifierMappings1_21.uuidToId(uuid);
|
||||||
|
if (id != null) {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
id = AttributeModifierMappings1_21.nameToId(name);
|
||||||
|
}
|
||||||
|
return id != null ? id : uuid.toString().toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UUID mapAttributeId(final String id) {
|
||||||
|
final UUID uuid = AttributeModifierMappings1_21.idToUuid(id);
|
||||||
|
return uuid != null ? uuid : UUID.randomUUID();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMappingDataLoaded() {
|
protected void onMappingDataLoaded() {
|
||||||
super.onMappingDataLoaded();
|
super.onMappingDataLoaded();
|
||||||
@ -97,9 +135,9 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol<ClientboundPack
|
|||||||
Types1_21.STRUCTURED_DATA.filler(this)
|
Types1_21.STRUCTURED_DATA.filler(this)
|
||||||
.add(StructuredDataKey.CUSTOM_DATA).add(StructuredDataKey.MAX_STACK_SIZE).add(StructuredDataKey.MAX_DAMAGE)
|
.add(StructuredDataKey.CUSTOM_DATA).add(StructuredDataKey.MAX_STACK_SIZE).add(StructuredDataKey.MAX_DAMAGE)
|
||||||
.add(StructuredDataKey.DAMAGE).add(StructuredDataKey.UNBREAKABLE).add(StructuredDataKey.RARITY)
|
.add(StructuredDataKey.DAMAGE).add(StructuredDataKey.UNBREAKABLE).add(StructuredDataKey.RARITY)
|
||||||
.add(StructuredDataKey.HIDE_TOOLTIP).add(StructuredDataKey.FOOD1_21).add(StructuredDataKey.FIRE_RESISTANT)
|
.add(StructuredDataKey.HIDE_TOOLTIP).add(StructuredDataKey.FIRE_RESISTANT)
|
||||||
.add(StructuredDataKey.CUSTOM_NAME).add(StructuredDataKey.LORE).add(StructuredDataKey.ENCHANTMENTS)
|
.add(StructuredDataKey.CUSTOM_NAME).add(StructuredDataKey.LORE).add(StructuredDataKey.ENCHANTMENTS)
|
||||||
.add(StructuredDataKey.CAN_PLACE_ON).add(StructuredDataKey.CAN_BREAK).add(StructuredDataKey.ATTRIBUTE_MODIFIERS)
|
.add(StructuredDataKey.CAN_PLACE_ON).add(StructuredDataKey.CAN_BREAK)
|
||||||
.add(StructuredDataKey.CUSTOM_MODEL_DATA).add(StructuredDataKey.HIDE_ADDITIONAL_TOOLTIP).add(StructuredDataKey.REPAIR_COST)
|
.add(StructuredDataKey.CUSTOM_MODEL_DATA).add(StructuredDataKey.HIDE_ADDITIONAL_TOOLTIP).add(StructuredDataKey.REPAIR_COST)
|
||||||
.add(StructuredDataKey.CREATIVE_SLOT_LOCK).add(StructuredDataKey.ENCHANTMENT_GLINT_OVERRIDE).add(StructuredDataKey.INTANGIBLE_PROJECTILE)
|
.add(StructuredDataKey.CREATIVE_SLOT_LOCK).add(StructuredDataKey.ENCHANTMENT_GLINT_OVERRIDE).add(StructuredDataKey.INTANGIBLE_PROJECTILE)
|
||||||
.add(StructuredDataKey.STORED_ENCHANTMENTS).add(StructuredDataKey.DYED_COLOR).add(StructuredDataKey.MAP_COLOR)
|
.add(StructuredDataKey.STORED_ENCHANTMENTS).add(StructuredDataKey.DYED_COLOR).add(StructuredDataKey.MAP_COLOR)
|
||||||
@ -113,7 +151,8 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol<ClientboundPack
|
|||||||
.add(StructuredDataKey.BANNER_PATTERNS).add(StructuredDataKey.BASE_COLOR).add(StructuredDataKey.POT_DECORATIONS)
|
.add(StructuredDataKey.BANNER_PATTERNS).add(StructuredDataKey.BASE_COLOR).add(StructuredDataKey.POT_DECORATIONS)
|
||||||
.add(StructuredDataKey.CONTAINER).add(StructuredDataKey.BLOCK_STATE).add(StructuredDataKey.BEES)
|
.add(StructuredDataKey.CONTAINER).add(StructuredDataKey.BLOCK_STATE).add(StructuredDataKey.BEES)
|
||||||
.add(StructuredDataKey.LOCK).add(StructuredDataKey.CONTAINER_LOOT).add(StructuredDataKey.TOOL)
|
.add(StructuredDataKey.LOCK).add(StructuredDataKey.CONTAINER_LOOT).add(StructuredDataKey.TOOL)
|
||||||
.add(StructuredDataKey.ITEM_NAME).add(StructuredDataKey.OMINOUS_BOTTLE_AMPLIFIER);
|
.add(StructuredDataKey.ITEM_NAME).add(StructuredDataKey.OMINOUS_BOTTLE_AMPLIFIER)
|
||||||
|
.add(StructuredDataKey.FOOD1_21).add(StructuredDataKey.JUKEBOX_PLAYABLE).add(StructuredDataKey.ATTRIBUTE_MODIFIERS1_21);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -142,10 +181,10 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PacketTypesProvider<ClientboundPacket1_20_5, ClientboundPacket1_20_5, ServerboundPacket1_20_5, ServerboundPacket1_20_5> createPacketTypesProvider() {
|
protected PacketTypesProvider<ClientboundPacket1_20_5, ClientboundPacket1_21, ServerboundPacket1_20_5, ServerboundPacket1_20_5> createPacketTypesProvider() {
|
||||||
return new SimplePacketTypesProvider<>(
|
return new SimplePacketTypesProvider<>(
|
||||||
packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_20_5.class, ClientboundConfigurationPackets1_20_5.class),
|
packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_20_5.class, ClientboundConfigurationPackets1_20_5.class),
|
||||||
packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_20_5.class, ClientboundConfigurationPackets1_20_5.class),
|
packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_21.class, ClientboundConfigurationPackets1_21.class),
|
||||||
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class),
|
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class),
|
||||||
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class)
|
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class)
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* 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.v1_20_5to1_21.data;
|
||||||
|
|
||||||
|
import com.google.common.collect.BiMap;
|
||||||
|
import com.google.common.collect.HashBiMap;
|
||||||
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
public final class AttributeModifierMappings1_21 {
|
||||||
|
private static final Map<UUID, String> ATTRIBUTE_MODIFIER_IDS = new HashMap<>();
|
||||||
|
private static final Map<String, UUID> ATTRIBUTE_MODIFIER_INVERSE_IDS = new HashMap<>();
|
||||||
|
private static final BiMap<String, String> ATTRIBUTE_MODIFIER_NAMES = HashBiMap.create(Map.of(
|
||||||
|
"Random spawn bonus", "random_spawn_bonus",
|
||||||
|
"Random zombie-spawn bonus", "zombie_random_spawn_bonus",
|
||||||
|
"Leader zombie bonus", "leader_zombie_bonus",
|
||||||
|
"Zombie reinforcement callee charge", "reinforcement_callee_charge",
|
||||||
|
"Zombie reinforcement caller charge", "reinforcement_caller_charge"
|
||||||
|
));
|
||||||
|
|
||||||
|
static {
|
||||||
|
add(-4483571535397864886L, -5989644940537681742L, "armor.body");
|
||||||
|
add(8144722948526719024L, -7778190119041365872L, "effect.slowness");
|
||||||
|
add(6967552254039378640L, -9116175396973475259L, "enchantment.aqua_affinity");
|
||||||
|
add(5279725409867744698L, -5150363631200102632L, "attacking");
|
||||||
|
add(148071211714102867L, -7685811609035173472L, "attacking");
|
||||||
|
add(6196088217904236654L, -7493791321850887290L, "effect.minining_fatigue");
|
||||||
|
add(-5084161844451524480L, -8859020046251006329L, "enchantment.soul_speed");
|
||||||
|
add(-7907339078496465106L, -8112074600724210224L, "enchantment.swift_sneak");
|
||||||
|
add(6688265815086220243L, -6545541163342161890L, "drinking");
|
||||||
|
add(8315164243412860989L, -6631520853640075966L, "creative_mode_block_range");
|
||||||
|
add(4389663563256579765L, -4827163546944004714L, "enchantment.efficiency");
|
||||||
|
add(6732612758648800940L, -5145707699103688244L, "effect.health_boost");
|
||||||
|
add(9079981369298536661L, -6728494925450710401L, "covered");
|
||||||
|
add(-1521481167610687786L, -8630419745734927691L, "effect.absorption");
|
||||||
|
add(-7473408062188862076L, -5872005994337939597L, "creative_mode_entity_range");
|
||||||
|
add(-3721396875562958315L, -5317020504214661337L, "effect.unluck");
|
||||||
|
add(-2861585646493481178L, -6113244764726669811L, "armor.leggings");
|
||||||
|
add(6718535547217657911L, -5386630269401489641L, "enchantment.sweeping_edge");
|
||||||
|
add(-7949229004988660584L, -7828611303000832459L, "effect.speed");
|
||||||
|
add(-8650171790042118250L, -5749650997644763080L, "enchantment.soul_speed");
|
||||||
|
add(551224288813600377L, -8734740027710371860L, "enchantment.respiration");
|
||||||
|
add(-7046399332347654691L, -6723081531683397260L, "suffocating");
|
||||||
|
add(7361814797886573596L, -8641397326606817395L, "sprinting");
|
||||||
|
add(-6972338111383059132L, -8978659762232839026L, "armor.chestplate");
|
||||||
|
add(-5371971015925809039L, -6062243582569928137L, "enchantment.fire_protection");
|
||||||
|
add(7245570952092733273L, -8449101711440750679L, "effect.strength");
|
||||||
|
add(-422425648963762075L, -5756800103171642205L, "base_attack_speed");
|
||||||
|
add(-4607081316629330256L, -7008565754814018370L, "effect.jump_boost");
|
||||||
|
add(271280981090454338L, -8746077033958322898L, "effect.luck");
|
||||||
|
add(2211131075215181206L, -5513857709499300658L, "powder_snow");
|
||||||
|
add(-8908768238899017377L, -8313820693701227669L, "armor.boots");
|
||||||
|
add(-5797418877589107702L, -6181652684028920077L, "effect.haste");
|
||||||
|
add(3086076556416732775L, -5150312587563650736L, "armor.helmet");
|
||||||
|
add(-5082757096938257406L, -4891139119377885130L, "baby");
|
||||||
|
add(2478452629826324956L, -7247530463494186011L, "effect.weakness");
|
||||||
|
add(4659420831966187055L, -5191473055587376048L, "enchantment.blast_protection");
|
||||||
|
add(7301951777949303281L, -6753860660653972126L, "evil");
|
||||||
|
add(8533189226688352746L, -8254757081029716377L, "baby");
|
||||||
|
add(1286946037536540352L, -5768092872487507967L, "enchantment.depth_strider");
|
||||||
|
add(-3801225194067177672L, -6586624321849018929L, "base_attack_damage");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable String uuidToId(final UUID uuid) {
|
||||||
|
return ATTRIBUTE_MODIFIER_IDS.get(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable UUID idToUuid(final String id) {
|
||||||
|
return ATTRIBUTE_MODIFIER_INVERSE_IDS.get(Key.stripMinecraftNamespace(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable String nameToId(final String name) {
|
||||||
|
return ATTRIBUTE_MODIFIER_NAMES.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @Nullable String idToName(final String id) {
|
||||||
|
return ATTRIBUTE_MODIFIER_NAMES.inverse().get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void add(final long msb, final long lsb, final String id) {
|
||||||
|
final UUID uuid = new UUID(msb, lsb);
|
||||||
|
ATTRIBUTE_MODIFIER_IDS.put(uuid, id);
|
||||||
|
ATTRIBUTE_MODIFIER_INVERSE_IDS.put(id, uuid);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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.v1_20_5to1_21.packet;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
|
|
||||||
|
public enum ClientboundConfigurationPackets1_21 implements ClientboundPacket1_21 {
|
||||||
|
|
||||||
|
COOKIE_REQUEST, // 0x00
|
||||||
|
CUSTOM_PAYLOAD, // 0x01
|
||||||
|
DISCONNECT, // 0x02
|
||||||
|
FINISH_CONFIGURATION, // 0x03
|
||||||
|
KEEP_ALIVE, // 0x04
|
||||||
|
PING, // 0x05
|
||||||
|
RESET_CHAT, // 0x06
|
||||||
|
REGISTRY_DATA, // 0x07
|
||||||
|
RESOURCE_PACK_POP, // 0x08
|
||||||
|
RESOURCE_PACK_PUSH, // 0x09
|
||||||
|
STORE_COOKIE, // 0x0A
|
||||||
|
TRANSFER, // 0x0B
|
||||||
|
UPDATE_ENABLED_FEATURES, // 0x0C
|
||||||
|
UPDATE_TAGS, // 0x0D
|
||||||
|
SELECT_KNOWN_PACKS, // 0x0E
|
||||||
|
CUSTOM_REPORT_DETAILS, // 0x0F
|
||||||
|
SERVER_LINKS; // 0x10
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public State state() {
|
||||||
|
return State.CONFIGURATION;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* 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.v1_20_5to1_21.packet;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
|
|
||||||
|
public interface ClientboundPacket1_21 extends ClientboundPacketType {
|
||||||
|
}
|
@ -0,0 +1,156 @@
|
|||||||
|
/*
|
||||||
|
* 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.v1_20_5to1_21.packet;
|
||||||
|
|
||||||
|
public enum ClientboundPackets1_21 implements ClientboundPacket1_21 {
|
||||||
|
|
||||||
|
BUNDLE_DELIMITER, // 0x00
|
||||||
|
ADD_ENTITY, // 0x01
|
||||||
|
ADD_EXPERIENCE_ORB, // 0x02
|
||||||
|
ANIMATE, // 0x03
|
||||||
|
AWARD_STATS, // 0x04
|
||||||
|
BLOCK_CHANGED_ACK, // 0x05
|
||||||
|
BLOCK_DESTRUCTION, // 0x06
|
||||||
|
BLOCK_ENTITY_DATA, // 0x07
|
||||||
|
BLOCK_EVENT, // 0x08
|
||||||
|
BLOCK_UPDATE, // 0x09
|
||||||
|
BOSS_EVENT, // 0x0A
|
||||||
|
CHANGE_DIFFICULTY, // 0x0B
|
||||||
|
CHUNK_BATCH_FINISHED, // 0x0C
|
||||||
|
CHUNK_BATCH_START, // 0x0D
|
||||||
|
CHUNKS_BIOMES, // 0x0E
|
||||||
|
CLEAR_TITLES, // 0x0F
|
||||||
|
COMMAND_SUGGESTIONS, // 0x10
|
||||||
|
COMMANDS, // 0x11
|
||||||
|
CONTAINER_CLOSE, // 0x12
|
||||||
|
CONTAINER_SET_CONTENT, // 0x13
|
||||||
|
CONTAINER_SET_DATA, // 0x14
|
||||||
|
CONTAINER_SET_SLOT, // 0x15
|
||||||
|
COOKIE_REQUEST, // 0x16
|
||||||
|
COOLDOWN, // 0x17
|
||||||
|
CUSTOM_CHAT_COMPLETIONS, // 0x18
|
||||||
|
CUSTOM_PAYLOAD, // 0x19
|
||||||
|
DAMAGE_EVENT, // 0x1A
|
||||||
|
DEBUG_SAMPLE, // 0x1B
|
||||||
|
DELETE_CHAT, // 0x1C
|
||||||
|
DISCONNECT, // 0x1D
|
||||||
|
DISGUISED_CHAT, // 0x1E
|
||||||
|
ENTITY_EVENT, // 0x1F
|
||||||
|
EXPLODE, // 0x20
|
||||||
|
FORGET_LEVEL_CHUNK, // 0x21
|
||||||
|
GAME_EVENT, // 0x22
|
||||||
|
HORSE_SCREEN_OPEN, // 0x23
|
||||||
|
HURT_ANIMATION, // 0x24
|
||||||
|
INITIALIZE_BORDER, // 0x25
|
||||||
|
KEEP_ALIVE, // 0x26
|
||||||
|
LEVEL_CHUNK_WITH_LIGHT, // 0x27
|
||||||
|
LEVEL_EVENT, // 0x28
|
||||||
|
LEVEL_PARTICLES, // 0x29
|
||||||
|
LIGHT_UPDATE, // 0x2A
|
||||||
|
LOGIN, // 0x2B
|
||||||
|
MAP_ITEM_DATA, // 0x2C
|
||||||
|
MERCHANT_OFFERS, // 0x2D
|
||||||
|
MOVE_ENTITY_POS, // 0x2E
|
||||||
|
MOVE_ENTITY_POS_ROT, // 0x2F
|
||||||
|
MOVE_ENTITY_ROT, // 0x30
|
||||||
|
MOVE_VEHICLE, // 0x31
|
||||||
|
OPEN_BOOK, // 0x32
|
||||||
|
OPEN_SCREEN, // 0x33
|
||||||
|
OPEN_SIGN_EDITOR, // 0x34
|
||||||
|
PING, // 0x35
|
||||||
|
PONG_RESPONSE, // 0x36
|
||||||
|
PLACE_GHOST_RECIPE, // 0x37
|
||||||
|
PLAYER_ABILITIES, // 0x38
|
||||||
|
PLAYER_CHAT, // 0x39
|
||||||
|
PLAYER_COMBAT_END, // 0x3A
|
||||||
|
PLAYER_COMBAT_ENTER, // 0x3B
|
||||||
|
PLAYER_COMBAT_KILL, // 0x3C
|
||||||
|
PLAYER_INFO_REMOVE, // 0x3D
|
||||||
|
PLAYER_INFO_UPDATE, // 0x3E
|
||||||
|
PLAYER_LOOK_AT, // 0x3F
|
||||||
|
PLAYER_POSITION, // 0x40
|
||||||
|
RECIPE, // 0x41
|
||||||
|
REMOVE_ENTITIES, // 0x42
|
||||||
|
REMOVE_MOB_EFFECT, // 0x43
|
||||||
|
RESET_SCORE, // 0x44
|
||||||
|
RESOURCE_PACK_POP, // 0x45
|
||||||
|
RESOURCE_PACK_PUSH, // 0x46
|
||||||
|
RESPAWN, // 0x47
|
||||||
|
ROTATE_HEAD, // 0x48
|
||||||
|
SECTION_BLOCKS_UPDATE, // 0x49
|
||||||
|
SELECT_ADVANCEMENTS_TAB, // 0x4A
|
||||||
|
SERVER_DATA, // 0x4B
|
||||||
|
SET_ACTION_BAR_TEXT, // 0x4C
|
||||||
|
SET_BORDER_CENTER, // 0x4D
|
||||||
|
SET_BORDER_LERP_SIZE, // 0x4E
|
||||||
|
SET_BORDER_SIZE, // 0x4F
|
||||||
|
SET_BORDER_WARNING_DELAY, // 0x50
|
||||||
|
SET_BORDER_WARNING_DISTANCE, // 0x51
|
||||||
|
SET_CAMERA, // 0x52
|
||||||
|
SET_CARRIED_ITEM, // 0x53
|
||||||
|
SET_CHUNK_CACHE_CENTER, // 0x54
|
||||||
|
SET_CHUNK_CACHE_RADIUS, // 0x55
|
||||||
|
SET_DEFAULT_SPAWN_POSITION, // 0x56
|
||||||
|
SET_DISPLAY_OBJECTIVE, // 0x57
|
||||||
|
SET_ENTITY_DATA, // 0x58
|
||||||
|
SET_ENTITY_LINK, // 0x59
|
||||||
|
SET_ENTITY_MOTION, // 0x5A
|
||||||
|
SET_EQUIPMENT, // 0x5B
|
||||||
|
SET_EXPERIENCE, // 0x5C
|
||||||
|
SET_HEALTH, // 0x5D
|
||||||
|
SET_OBJECTIVE, // 0x5E
|
||||||
|
SET_PASSENGERS, // 0x5F
|
||||||
|
SET_PLAYER_TEAM, // 0x60
|
||||||
|
SET_SCORE, // 0x61
|
||||||
|
SET_SIMULATION_DISTANCE, // 0x62
|
||||||
|
SET_SUBTITLE_TEXT, // 0x63
|
||||||
|
SET_TIME, // 0x64
|
||||||
|
SET_TITLE_TEXT, // 0x65
|
||||||
|
SET_TITLES_ANIMATION, // 0x66
|
||||||
|
SOUND_ENTITY, // 0x67
|
||||||
|
SOUND, // 0x68
|
||||||
|
START_CONFIGURATION, // 0x69
|
||||||
|
STOP_SOUND, // 0x6A
|
||||||
|
STORE_COOKIE, // 0x6B
|
||||||
|
SYSTEM_CHAT, // 0x6C
|
||||||
|
TAB_LIST, // 0x6D
|
||||||
|
TAG_QUERY, // 0x6E
|
||||||
|
TAKE_ITEM_ENTITY, // 0x6F
|
||||||
|
TELEPORT_ENTITY, // 0x70
|
||||||
|
TICKING_STATE, // 0x71
|
||||||
|
TICKING_STEP, // 0x72
|
||||||
|
TRANSFER, // 0x73
|
||||||
|
UPDATE_ADVANCEMENTS, // 0x74
|
||||||
|
UPDATE_ATTRIBUTES, // 0x75
|
||||||
|
UPDATE_MOB_EFFECT, // 0x76
|
||||||
|
UPDATE_RECIPES, // 0x77
|
||||||
|
UPDATE_TAGS, // 0x78
|
||||||
|
PROJECTILE_POWER, // 0x79
|
||||||
|
CUSTOM_REPORT_DETAILS, // 0x7A
|
||||||
|
SERVER_LINKS; // 0x7B
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name();
|
||||||
|
}
|
||||||
|
}
|
@ -18,20 +18,25 @@
|
|||||||
package com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter;
|
package com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_20_5;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_21;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_21;
|
import com.viaversion.viaversion.api.type.types.version.Types1_21;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.RecipeRewriter1_20_3;
|
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.RecipeRewriter1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.data.AttributeModifierMappings1_21;
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
|
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
|
||||||
|
import java.util.Arrays;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter<ClientboundPacket1_20_5, ServerboundPacket1_20_5, Protocol1_20_5To1_21> {
|
public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter<ClientboundPacket1_20_5, ServerboundPacket1_20_5, Protocol1_20_5To1_21> {
|
||||||
@ -79,10 +84,23 @@ public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter<Cl
|
|||||||
}
|
}
|
||||||
|
|
||||||
super.handleItemToClient(connection, item);
|
super.handleItemToClient(connection, item);
|
||||||
item.structuredData().replaceKey(StructuredDataKey.FOOD1_20_5, StructuredDataKey.FOOD1_21);
|
updateItemData(item);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateItemData(final Item item) {
|
||||||
|
final StructuredDataContainer dataContainer = item.structuredData();
|
||||||
|
dataContainer.replaceKey(StructuredDataKey.FOOD1_20_5, StructuredDataKey.FOOD1_21);
|
||||||
|
dataContainer.replace(StructuredDataKey.ATTRIBUTE_MODIFIERS1_20_5, StructuredDataKey.ATTRIBUTE_MODIFIERS1_21, attributeModifiers -> {
|
||||||
|
final AttributeModifiers1_21.AttributeModifier[] modifiers = Arrays.stream(attributeModifiers.modifiers()).map(modifier -> {
|
||||||
|
final AttributeModifiers1_20_5.ModifierData modData = modifier.modifier();
|
||||||
|
final AttributeModifiers1_21.ModifierData updatedModData = new AttributeModifiers1_21.ModifierData(Protocol1_20_5To1_21.mapAttributeUUID(modData.uuid(), modData.name()), modData.amount(), modData.operation());
|
||||||
|
return new AttributeModifiers1_21.AttributeModifier(modifier.attribute(), updatedModData, modifier.slotType());
|
||||||
|
}).toArray(AttributeModifiers1_21.AttributeModifier[]::new);
|
||||||
|
return new AttributeModifiers1_21(modifiers, attributeModifiers.showInTooltip());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Item handleItemToServer(final UserConnection connection, @Nullable final Item item) {
|
public @Nullable Item handleItemToServer(final UserConnection connection, @Nullable final Item item) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
@ -90,7 +108,27 @@ public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter<Cl
|
|||||||
}
|
}
|
||||||
|
|
||||||
super.handleItemToServer(connection, item);
|
super.handleItemToServer(connection, item);
|
||||||
item.structuredData().replaceKey(StructuredDataKey.FOOD1_21, StructuredDataKey.FOOD1_20_5);
|
downgradeItemData(item);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void downgradeItemData(final Item item) {
|
||||||
|
final StructuredDataContainer dataContainer = item.structuredData();
|
||||||
|
dataContainer.replaceKey(StructuredDataKey.FOOD1_21, StructuredDataKey.FOOD1_20_5);
|
||||||
|
dataContainer.remove(StructuredDataKey.JUKEBOX_PLAYABLE);
|
||||||
|
dataContainer.replace(StructuredDataKey.ATTRIBUTE_MODIFIERS1_21, StructuredDataKey.ATTRIBUTE_MODIFIERS1_20_5, attributeModifiers -> {
|
||||||
|
final AttributeModifiers1_20_5.AttributeModifier[] modifiers = Arrays.stream(attributeModifiers.modifiers()).map(modifier -> {
|
||||||
|
final AttributeModifiers1_21.ModifierData modData = modifier.modifier();
|
||||||
|
final String name = AttributeModifierMappings1_21.idToName(modData.id());
|
||||||
|
final AttributeModifiers1_20_5.ModifierData updatedModData = new AttributeModifiers1_20_5.ModifierData(
|
||||||
|
Protocol1_20_5To1_21.mapAttributeId(modData.id()),
|
||||||
|
name != null ? name : modData.id(),
|
||||||
|
modData.amount(),
|
||||||
|
modData.operation()
|
||||||
|
);
|
||||||
|
return new AttributeModifiers1_20_5.AttributeModifier(modifier.attribute(), updatedModData, modifier.slotType());
|
||||||
|
}).toArray(AttributeModifiers1_20_5.AttributeModifier[]::new);
|
||||||
|
return new AttributeModifiers1_20_5(modifiers, attributeModifiers.showInTooltip());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
@ -28,7 +28,7 @@ public class AttributeRewriter<C extends ClientboundPacketType> {
|
|||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register1_20_5(C packetType) {
|
public void register1_21(C packetType) {
|
||||||
protocol.registerClientbound(packetType, wrapper -> {
|
protocol.registerClientbound(packetType, wrapper -> {
|
||||||
wrapper.passthrough(Types.VAR_INT); // Entity ID
|
wrapper.passthrough(Types.VAR_INT); // Entity ID
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ public class AttributeRewriter<C extends ClientboundPacketType> {
|
|||||||
wrapper.read(Types.DOUBLE); // Base
|
wrapper.read(Types.DOUBLE); // Base
|
||||||
final int modifierSize = wrapper.read(Types.VAR_INT);
|
final int modifierSize = wrapper.read(Types.VAR_INT);
|
||||||
for (int j = 0; j < modifierSize; j++) {
|
for (int j = 0; j < modifierSize; j++) {
|
||||||
wrapper.read(Types.UUID); // ID
|
wrapper.read(Types.STRING); // ID
|
||||||
wrapper.read(Types.DOUBLE); // Amount
|
wrapper.read(Types.DOUBLE); // Amount
|
||||||
wrapper.read(Types.BYTE); // Operation
|
wrapper.read(Types.BYTE); // Operation
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ public class AttributeRewriter<C extends ClientboundPacketType> {
|
|||||||
wrapper.passthrough(Types.DOUBLE); // Base
|
wrapper.passthrough(Types.DOUBLE); // Base
|
||||||
final int modifierSize = wrapper.passthrough(Types.VAR_INT);
|
final int modifierSize = wrapper.passthrough(Types.VAR_INT);
|
||||||
for (int j = 0; j < modifierSize; j++) {
|
for (int j = 0; j < modifierSize; j++) {
|
||||||
wrapper.passthrough(Types.UUID); // ID
|
wrapper.passthrough(Types.STRING); // ID
|
||||||
wrapper.passthrough(Types.DOUBLE); // Amount
|
wrapper.passthrough(Types.DOUBLE); // Amount
|
||||||
wrapper.passthrough(Types.BYTE); // Operation
|
wrapper.passthrough(Types.BYTE); // Operation
|
||||||
}
|
}
|
||||||
|
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
@ -1,5 +1,5 @@
|
|||||||
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
|
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
|
||||||
projectVersion=5.0.0-24w20a-SNAPSHOT
|
projectVersion=5.0.0-24w21b-SNAPSHOT
|
||||||
|
|
||||||
# Smile emoji
|
# Smile emoji
|
||||||
mcVersions=1.20.6,1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9
|
mcVersions=1.20.6,1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9
|
||||||
|
@ -70,7 +70,7 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
|
|||||||
soundRewriter.registerSound1_19_3(ClientboundPackets1_20_5.SOUND_ENTITY);
|
soundRewriter.registerSound1_19_3(ClientboundPackets1_20_5.SOUND_ENTITY);
|
||||||
|
|
||||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_5.AWARD_STATS);
|
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_5.AWARD_STATS);
|
||||||
new AttributeRewriter<>(this).register1_20_5(ClientboundPackets1_20_5.UPDATE_ATTRIBUTES);
|
new AttributeRewriter<>(this).register1_21(ClientboundPackets1_20_5.UPDATE_ATTRIBUTES);
|
||||||
|
|
||||||
// Uncomment if an existing type changed serialization format. Mappings for argument type keys can also be defined in mapping files
|
// Uncomment if an existing type changed serialization format. Mappings for argument type keys can also be defined in mapping files
|
||||||
/*final CommandRewriter1_19_4<ClientboundPackets1_20_5> commandRewriter = new CommandRewriter1_19_4<ClientboundPackets1_20_5>(this) {
|
/*final CommandRewriter1_19_4<ClientboundPackets1_20_5> commandRewriter = new CommandRewriter1_19_4<ClientboundPackets1_20_5>(this) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren