mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2026-11-04 17:00:06 -05:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87cb733061 | ||
|
|
e813796d9a | ||
|
|
271b6e7ff7 | ||
|
|
7bf4a30075 | ||
|
|
414e978829 | ||
|
|
637a81e569 | ||
|
|
b4023127f6 | ||
|
|
46a61058dd | ||
|
|
66b90a5b2a | ||
|
|
8f03d6bcef |
No files matched your search
@@ -26,6 +26,8 @@ import com.viaversion.nbt.tag.ByteArrayTag;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import java.util.function.IntConsumer;
|
||||
@@ -49,6 +51,12 @@ public final class IdRanges {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public static IntList decodeAsList(final ByteArrayTag rangesTag) {
|
||||
final IntList ids = new IntArrayList();
|
||||
forEachId(rangesTag, ids::add);
|
||||
return ids;
|
||||
}
|
||||
|
||||
public static void forEachId(final ByteArrayTag rangesTag, final IntConsumer consumer) {
|
||||
final ByteBuf buf = Unpooled.wrappedBuffer(rangesTag.getValue());
|
||||
int prevEnd = 0;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.api.data;
|
||||
|
||||
import com.viaversion.nbt.tag.ByteArrayTag;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.IntArrayTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
@@ -198,8 +199,14 @@ public class MappingDataBase implements MappingData {
|
||||
|
||||
final List<TagData> tagsList = new ArrayList<>(tags.size());
|
||||
for (final Map.Entry<String, Tag> entry : tag.entrySet()) {
|
||||
final IntArrayTag entries = (IntArrayTag) entry.getValue();
|
||||
tagsList.add(new TagData(entry.getKey(), entries.getValue()));
|
||||
final int[] entries;
|
||||
if (entry.getValue() instanceof final ByteArrayTag rangesTag) {
|
||||
entries = IdRanges.decodeAsList(rangesTag).toIntArray();
|
||||
} else {
|
||||
// Old format / if the values need to be sorted
|
||||
entries = ((IntArrayTag) entry.getValue()).getValue();
|
||||
}
|
||||
tagsList.add(new TagData(entry.getKey(), entries));
|
||||
}
|
||||
|
||||
this.tags.put(type, tagsList);
|
||||
|
||||
+2
-3
@@ -37,7 +37,6 @@ import com.viaversion.viaversion.util.Rewritable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
// TODO move block state provider rewriting to registry data rewriter
|
||||
public record BlockTransformData(CompoundTag blockStateProvider, Holder<SoundEvent> sound, int transformParticle,
|
||||
int[] disallowedFaces, @Nullable String loot, int dropStrategy,
|
||||
boolean updateFromNeighbors, int transformType,
|
||||
@@ -82,9 +81,9 @@ public record BlockTransformData(CompoundTag blockStateProvider, Holder<SoundEve
|
||||
.writeOptional("particle", EnumTypes.TRANSFORM_PARTICLE, data.transformParticle, 0)
|
||||
.writeOptional("disallowed_faces", EnumTypes.DIRECTION.new EnumArrayType(), data.disallowedFaces, new int[0])
|
||||
.writeOptional("loot", Types.STRING, data.loot)
|
||||
.writeOptional("drop_strategy", Types.VAR_INT, data.dropStrategy, 1)
|
||||
.writeOptional("drop_strategy", EnumTypes.TRAMNSFORM_DROP_STRATEGY, data.dropStrategy, 1)
|
||||
.writeOptional("update_from_neighbors", Types.BOOLEAN, data.updateFromNeighbors, true)
|
||||
.writeOptional("transform_type", Types.VAR_INT, data.transformType, 0)
|
||||
.writeOptional("transform_type", EnumTypes.TRAMNSFORM_TYPE, data.transformType, 0)
|
||||
.writeOptional("consume_on_use", Types.BOOLEAN, data.consumeOnUse, true)
|
||||
.writeOptional("item_damage_per_use", Types.VAR_INT, data.itemDamagePerUse, 0)
|
||||
);
|
||||
|
||||
+2
-2
@@ -34,7 +34,6 @@ import io.netty.buffer.ByteBuf;
|
||||
// Very similar to normal items (and just results in an item), except it allows non-positive amounts and has id/amount swapped because ???
|
||||
public final class ItemCostType1_20_5 extends Type<Item> {
|
||||
|
||||
private static final StructuredData<?>[] EMPTY_DATA_ARRAY = new StructuredData[0];
|
||||
private final Type<StructuredData<?>[]> dataArrayType;
|
||||
|
||||
public ItemCostType1_20_5(final Type<StructuredData<?>[]> dataArrayType) {
|
||||
@@ -54,7 +53,8 @@ public final class ItemCostType1_20_5 extends Type<Item> {
|
||||
public void write(final ByteBuf buffer, final Item object) {
|
||||
Types.VAR_INT.writePrimitive(buffer, object.identifier());
|
||||
Types.VAR_INT.writePrimitive(buffer, object.amount());
|
||||
dataArrayType.write(buffer, object.dataContainer().data().values().toArray(EMPTY_DATA_ARRAY));
|
||||
// Item costs are exact-match predicates without removal markers, so empty data can't be written
|
||||
dataArrayType.write(buffer, object.dataContainer().data().values().stream().filter(StructuredData::isPresent).toArray(StructuredData[]::new));
|
||||
}
|
||||
|
||||
public static final class OptionalItemCostType extends OptionalType<Item> {
|
||||
|
||||
+2
@@ -51,6 +51,7 @@ import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.rewriter.ComponentRew
|
||||
import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.rewriter.EntityPacketRewriter1_19_3;
|
||||
import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.rewriter.ItemPacketRewriter1_19_3;
|
||||
import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.storage.NonceStorage1_19_3;
|
||||
import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.storage.PlayerHealthStorage;
|
||||
import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.storage.ReceivedMessagesStorage;
|
||||
import com.viaversion.viaversion.protocols.v1_19to1_19_1.packet.ClientboundPackets1_19_1;
|
||||
import com.viaversion.viaversion.protocols.v1_19to1_19_1.packet.ServerboundPackets1_19_1;
|
||||
@@ -380,6 +381,7 @@ public final class Protocol1_19_1To1_19_3 extends AbstractProtocol<ClientboundPa
|
||||
@Override
|
||||
public void init(final UserConnection user) {
|
||||
user.put(new ReceivedMessagesStorage());
|
||||
user.put(new PlayerHealthStorage());
|
||||
addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_19_3.PLAYER));
|
||||
}
|
||||
|
||||
|
||||
+20
@@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_3;
|
||||
import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.Protocol1_19_1To1_19_3;
|
||||
import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.packet.ClientboundPackets1_19_3;
|
||||
import com.viaversion.viaversion.protocols.v1_19_1to1_19_3.storage.PlayerHealthStorage;
|
||||
import com.viaversion.viaversion.protocols.v1_19to1_19_1.packet.ClientboundPackets1_19_1;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import java.util.BitSet;
|
||||
@@ -75,6 +76,13 @@ public final class EntityPacketRewriter1_19_3 extends EntityRewriter<Clientbound
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_1.SET_HEALTH, wrapper -> {
|
||||
final float health = wrapper.passthrough(Types.FLOAT);
|
||||
final int food = wrapper.passthrough(Types.VAR_INT);
|
||||
final float saturation = wrapper.passthrough(Types.FLOAT);
|
||||
wrapper.user().get(PlayerHealthStorage.class).update(health, food, saturation);
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_1.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
@@ -94,6 +102,18 @@ public final class EntityPacketRewriter1_19_3 extends EntityRewriter<Clientbound
|
||||
}
|
||||
wrapper.write(Types.BYTE, keepDataMask);
|
||||
});
|
||||
handler(wrapper -> {
|
||||
final PlayerHealthStorage healthStorage = wrapper.user().get(PlayerHealthStorage.class);
|
||||
if (healthStorage.dead()) {
|
||||
// The client takes over the entity data of the dead player, its health of 0 would instantly re-open the death screen
|
||||
final PacketWrapper setHealth = wrapper.create(ClientboundPackets1_19_3.SET_HEALTH);
|
||||
setHealth.write(Types.FLOAT, 20F); // Overwritten by the server right after the respawn
|
||||
setHealth.write(Types.VAR_INT, healthStorage.food());
|
||||
setHealth.write(Types.FLOAT, healthStorage.saturation());
|
||||
setHealth.send(Protocol1_19_1To1_19_3.class);
|
||||
healthStorage.setDead(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2026 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_19_1to1_19_3.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public final class PlayerHealthStorage implements StorableObject {
|
||||
|
||||
private boolean dead;
|
||||
private int food;
|
||||
private float saturation;
|
||||
|
||||
public void update(final float health, final int food, final float saturation) {
|
||||
this.dead = health <= 0;
|
||||
this.food = food;
|
||||
this.saturation = saturation;
|
||||
}
|
||||
|
||||
public boolean dead() {
|
||||
return this.dead;
|
||||
}
|
||||
|
||||
public void setDead(final boolean dead) {
|
||||
this.dead = dead;
|
||||
}
|
||||
|
||||
public int food() {
|
||||
return this.food;
|
||||
}
|
||||
|
||||
public float saturation() {
|
||||
return this.saturation;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -215,9 +215,10 @@ public final class Protocol1_20_5To1_21 extends AbstractProtocol<ClientboundPack
|
||||
tagRewriter.addEmptyTags(RegistryType.ENTITY, "minecraft:can_turn_in_boats", "minecraft:deflects_projectiles", "minecraft:immune_to_infested",
|
||||
"minecraft:immune_to_oozing", "minecraft:no_anger_from_wind_charge");
|
||||
tagRewriter.addTag(RegistryType.ENCHANTMENT, "minecraft:curse", 10, 41); // Binding and vanishing curse
|
||||
tagRewriter.addTag(RegistryType.ENCHANTMENT, "minecraft:prevents_decorated_pot_shattering", 21); // Silk touch
|
||||
// Add other enchantment tags empty
|
||||
tagRewriter.addEmptyTags(RegistryType.ENCHANTMENT, "double_trade_price", "in_enchanting_table", "non_treasure", "on_mob_spawn_equipment", "on_random_loot",
|
||||
"on_traded_equipment", "prevents_bee_spawns_when_mining", "prevents_decorated_pot_shattering", "prevents_ice_melting", "prevents_infested_spawns", "smelts_loot",
|
||||
"on_traded_equipment", "prevents_bee_spawns_when_mining", "prevents_ice_melting", "prevents_infested_spawns", "smelts_loot",
|
||||
"tooltip_order", "tradeable", "treasure", "exclusive_set/armor", "exclusive_set/boots", "exclusive_set/bow", "exclusive_set/crossbow", "exclusive_set/damage",
|
||||
"exclusive_set/mining", "exclusive_set/riptide");
|
||||
}
|
||||
|
||||
+4
@@ -22,6 +22,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.MappingData;
|
||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||
import com.viaversion.viaversion.api.minecraft.Holder;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_4;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_5;
|
||||
@@ -191,6 +192,9 @@ public final class Protocol1_21_4To1_21_5 extends AbstractProtocol<ClientboundPa
|
||||
StructuredDataKey.PAINTING_VARIANT, StructuredDataKey.LLAMA_VARIANT, StructuredDataKey.AXOLOTL_VARIANT, StructuredDataKey.CAT_VARIANT,
|
||||
StructuredDataKey.CAT_COLLAR, StructuredDataKey.SHEEP_COLOR, StructuredDataKey.SHULKER_COLOR, StructuredDataKey.PROVIDES_TRIM_MATERIAL1_21_5,
|
||||
StructuredDataKey.BREAK_SOUND, StructuredDataKey.COW_VARIANT, StructuredDataKey.CHICKEN_VARIANT1_21_5, StructuredDataKey.WOLF_SOUND_VARIANT);
|
||||
|
||||
tagRewriter.renameTag(RegistryType.BLOCK, "dead_bush_may_place_on", "dry_vegetation_may_place_on");
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -21,6 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.MappingData;
|
||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||
import com.viaversion.viaversion.api.minecraft.GameMode;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_6;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
@@ -141,6 +142,9 @@ public final class Protocol1_21_5To1_21_6 extends AbstractProtocol<ClientboundPa
|
||||
StructuredDataKey.PAINTING_VARIANT, StructuredDataKey.LLAMA_VARIANT, StructuredDataKey.AXOLOTL_VARIANT, StructuredDataKey.CAT_VARIANT,
|
||||
StructuredDataKey.CAT_COLLAR, StructuredDataKey.SHEEP_COLOR, StructuredDataKey.SHULKER_COLOR, StructuredDataKey.PROVIDES_TRIM_MATERIAL1_21_5,
|
||||
StructuredDataKey.BREAK_SOUND, StructuredDataKey.COW_VARIANT, StructuredDataKey.CHICKEN_VARIANT1_21_5, StructuredDataKey.WOLF_SOUND_VARIANT);
|
||||
|
||||
tagRewriter.renameTag(RegistryType.BLOCK, "plays_ambient_desert_block_sounds", "triggers_ambient_desert_dry_vegetation_block_sounds");
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -216,6 +216,11 @@ public class SpawnPacketRewriter1_9 {
|
||||
int entityID = wrapper.get(Types.VAR_INT, 0);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(protocol);
|
||||
tracker.handleEntityData(entityID, entityDataList);
|
||||
|
||||
// dragon default phase on 1.9+ is 10 (hovering), so we set it to match the only phase 1.8 had, which was 0 (circling)
|
||||
if (tracker.entityType(entityID) == EntityTypes1_9.EntityType.ENDER_DRAGON) {
|
||||
entityDataList.add(new EntityData(11, EntityDataTypes1_9.VAR_INT, 0)); // 11 = dragon phase id
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+66
-1
@@ -17,10 +17,14 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.protocols.v26_2to26_3;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.MappingData;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockPosition;
|
||||
import com.viaversion.viaversion.api.minecraft.HolderSet;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.minecraft.data.version.StructuredDataKeys26_2;
|
||||
import com.viaversion.viaversion.api.minecraft.data.version.StructuredDataKeys26_3;
|
||||
@@ -67,6 +71,36 @@ import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
|
||||
public final class Protocol26_2To26_3 extends AbstractProtocol<ClientboundPacket26_1, ClientboundPacket26_3, ServerboundPacket26_1, ServerboundPacket26_3> {
|
||||
|
||||
public static final MappingData26_3 MAPPINGS = new MappingData26_3();
|
||||
private static final int SPLASH_POTION_SOUND = 1053;
|
||||
private static final int INSTANT_SPLASH_POTION_SOUND = 1054;
|
||||
private static final int SPLASH_POTION_PARTICLES = 2002;
|
||||
private static final int INSTANT_SPLASH_POTION_PARTICLES = 2007;
|
||||
private static final String[] POT_PATTERNS = {
|
||||
"angler",
|
||||
"archer",
|
||||
"arms_up",
|
||||
"blade",
|
||||
"brewer",
|
||||
"burn",
|
||||
"danger",
|
||||
"explorer",
|
||||
"flow",
|
||||
"friend",
|
||||
"guster",
|
||||
"heart",
|
||||
"heartbreak",
|
||||
"howl",
|
||||
"miner",
|
||||
"mourner",
|
||||
"plenty",
|
||||
"prize",
|
||||
"scrape",
|
||||
"sheaf",
|
||||
"shelter",
|
||||
"skull",
|
||||
"snort"
|
||||
|
||||
};
|
||||
private final EntityPacketRewriter26_3 entityRewriter = new EntityPacketRewriter26_3(this);
|
||||
private final BlockItemPacketRewriter26_3 itemRewriter = new BlockItemPacketRewriter26_3(this);
|
||||
private final BlockRewriter<ClientboundPacket26_1> blockRewriter = new BlockPacketRewriter26_3(this);
|
||||
@@ -98,7 +132,14 @@ public final class Protocol26_2To26_3 extends AbstractProtocol<ClientboundPacket
|
||||
appendClientbound(ClientboundConfigurationPackets1_21_9.FINISH_CONFIGURATION, wrapper -> {
|
||||
final PacketWrapper clocksPacket = wrapper.create(ClientboundConfigurationPackets26_3.REGISTRY_DATA);
|
||||
clocksPacket.write(Types.STRING, "decorated_pot_pattern");
|
||||
clocksPacket.write(Types.REGISTRY_ENTRY_ARRAY, MAPPINGS.potPatterns());
|
||||
final RegistryEntry[] entries = new RegistryEntry[POT_PATTERNS.length];
|
||||
for (int i = 0; i < POT_PATTERNS.length; i++) {
|
||||
final String key = POT_PATTERNS[i];
|
||||
final CompoundTag tag = new CompoundTag();
|
||||
tag.putString("asset_id", key + "_pottery_pattern");
|
||||
entries[i] = new RegistryEntry(key, tag);
|
||||
}
|
||||
clocksPacket.write(Types.REGISTRY_ENTRY_ARRAY, entries);
|
||||
clocksPacket.send(Protocol26_2To26_3.class);
|
||||
|
||||
final PacketWrapper blockTransformersPacket = wrapper.create(ClientboundConfigurationPackets26_3.REGISTRY_DATA);
|
||||
@@ -137,6 +178,27 @@ public final class Protocol26_2To26_3 extends AbstractProtocol<ClientboundPacket
|
||||
componentRewriter.processTag(wrapper.user(), wrapper.passthrough(Types.TRUSTED_OPTIONAL_TAG)); // Target Name
|
||||
});
|
||||
|
||||
// 26.3 plays the potion splash sound through its own level event, older clients played it together with the particles
|
||||
appendClientbound(ClientboundPackets26_1.LEVEL_EVENT, wrapper -> {
|
||||
final int id = wrapper.get(Types.INT, 0);
|
||||
final BlockPosition position = wrapper.get(Types.BLOCK_POSITION1_14, 0);
|
||||
final int soundId;
|
||||
if (id == SPLASH_POTION_PARTICLES) {
|
||||
soundId = SPLASH_POTION_SOUND;
|
||||
} else if (id == INSTANT_SPLASH_POTION_PARTICLES) {
|
||||
soundId = INSTANT_SPLASH_POTION_SOUND;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
final PacketWrapper soundPacket = wrapper.create(ClientboundPackets26_3.LEVEL_EVENT);
|
||||
soundPacket.write(Types.INT, soundId);
|
||||
soundPacket.write(Types.BLOCK_POSITION1_14, position);
|
||||
soundPacket.write(Types.INT, 0); // Data
|
||||
soundPacket.write(Types.BOOLEAN, false); // Global
|
||||
soundPacket.scheduleSend(Protocol26_2To26_3.class);
|
||||
});
|
||||
|
||||
// 26.3 reads the items the brewing stand slots accept from the server, older clients have them hardcoded
|
||||
appendClientbound(ClientboundPackets26_1.UPDATE_RECIPES, wrapper -> {
|
||||
wrapper.resetReader();
|
||||
@@ -186,6 +248,9 @@ public final class Protocol26_2To26_3 extends AbstractProtocol<ClientboundPacket
|
||||
StructuredDataKey.PROVIDES_POTTERY_PATTERN, StructuredDataKey.BLOCK_TRANSFORMER, StructuredDataKey.COMPOSTABLE, StructuredDataKey.VILLAGER_FOOD,
|
||||
StructuredDataKey.COOKING_FUEL, StructuredDataKey.BREWING_FUEL, StructuredDataKey.MOB_VISIBILITY, StructuredDataKey.SIGN_TEXT_BACK, StructuredDataKey.SIGN_TEXT_FRONT,
|
||||
StructuredDataKey.WAXED, StructuredDataKey.CUSHION_COLOR, StructuredDataKey.ATTACK_ANIMATION, StructuredDataKey.INTERACT_ANIMATION);
|
||||
|
||||
tagRewriter.renameTag(RegistryType.BLOCK, "convertable_to_mud", "convertible_to_mud");
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
|
||||
+17
-41
@@ -20,15 +20,16 @@ package com.viaversion.viaversion.protocols.v26_2to26_3.data;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
||||
import java.util.Arrays;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
|
||||
public final class MappingData26_3 extends MappingDataBase {
|
||||
|
||||
private static final String[] BREWING_INPUTS = {
|
||||
"potion",
|
||||
"splash_potion",
|
||||
"lingering_potion"
|
||||
"lingering_potion",
|
||||
"glass_bottle"
|
||||
};
|
||||
private static final String[] BREWING_REAGENTS = {
|
||||
"blaze_powder",
|
||||
@@ -53,31 +54,6 @@ public final class MappingData26_3 extends MappingDataBase {
|
||||
"sugar",
|
||||
"turtle_helmet"
|
||||
};
|
||||
private static final String[] POT_PATTERNS = {
|
||||
"angler",
|
||||
"archer",
|
||||
"arms_up",
|
||||
"blade",
|
||||
"brewer",
|
||||
"burn",
|
||||
"danger",
|
||||
"explorer",
|
||||
"flow",
|
||||
"friend",
|
||||
"guster",
|
||||
"heart",
|
||||
"heartbreak",
|
||||
"howl",
|
||||
"miner",
|
||||
"mourner",
|
||||
"plenty",
|
||||
"prize",
|
||||
"scrape",
|
||||
"sheaf",
|
||||
"shelter",
|
||||
"skull",
|
||||
"snort"
|
||||
};
|
||||
|
||||
private CompoundTag blockTransformerRegistry;
|
||||
private int[] brewingInputIds;
|
||||
@@ -91,25 +67,25 @@ public final class MappingData26_3 extends MappingDataBase {
|
||||
protected void loadExtras(final CompoundTag data) {
|
||||
blockTransformerRegistry = MappingDataLoader.INSTANCE.loadNBTFromFile("block-transformer-registry-26.3.nbt");
|
||||
|
||||
brewingInputIds = Arrays.stream(BREWING_INPUTS).mapToInt(identifier -> this.getFullItemMappings().mappedId(identifier)).toArray();
|
||||
brewingReagentIds = Arrays.stream(BREWING_REAGENTS).mapToInt(identifier -> this.getFullItemMappings().mappedId(identifier)).toArray();
|
||||
brewingInputIds = itemIds(BREWING_INPUTS);
|
||||
brewingReagentIds = itemIds(BREWING_REAGENTS);
|
||||
}
|
||||
|
||||
private int[] itemIds(final String[] identifiers) {
|
||||
final IntList ids = new IntArrayList(identifiers.length);
|
||||
for (final String identifier : identifiers) {
|
||||
final int id = getFullItemMappings().mappedId(identifier);
|
||||
if (id != -1) {
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
return ids.toIntArray();
|
||||
}
|
||||
|
||||
public CompoundTag blockTransformerRegistry() {
|
||||
return blockTransformerRegistry;
|
||||
}
|
||||
|
||||
public RegistryEntry[] potPatterns() {
|
||||
final RegistryEntry[] entries = new RegistryEntry[POT_PATTERNS.length];
|
||||
for (int i = 0; i < POT_PATTERNS.length; i++) {
|
||||
final String key = POT_PATTERNS[i];
|
||||
final CompoundTag tag = new CompoundTag();
|
||||
tag.putString("asset_id", key + "_pottery_pattern");
|
||||
entries[i] = new RegistryEntry(key, tag);
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
public int[] brewingInputIds() {
|
||||
return brewingInputIds;
|
||||
}
|
||||
|
||||
+21
@@ -36,6 +36,7 @@ import com.viaversion.viaversion.api.minecraft.item.data.trim.ArmorTrim26_3;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.trim.ArmorTrimMaterial1_20_5;
|
||||
import com.viaversion.viaversion.api.minecraft.item.data.trim.ArmorTrimMaterial26_3;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
|
||||
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPacket26_1;
|
||||
@@ -201,6 +202,10 @@ public final class BlockItemPacketRewriter26_3 extends StructuredItemRewriter<Cl
|
||||
@Override
|
||||
protected void handleItemDataComponentsToClient(final UserConnection connection, final Item item, final StructuredDataContainer container) {
|
||||
upgradeData(container);
|
||||
|
||||
// Add data components to fix issues in older protocols
|
||||
appendItemDataFixComponents(connection, item, container);
|
||||
|
||||
super.handleItemDataComponentsToClient(connection, item, container);
|
||||
}
|
||||
|
||||
@@ -210,6 +215,22 @@ public final class BlockItemPacketRewriter26_3 extends StructuredItemRewriter<Cl
|
||||
super.handleItemDataComponentsToServer(connection, item, container);
|
||||
}
|
||||
|
||||
private void appendItemDataFixComponents(final UserConnection connection, final Item item, final StructuredDataContainer container) {
|
||||
final ProtocolVersion serverVersion = connection.getProtocolInfo().serverProtocolVersion();
|
||||
if (serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_12_2)) {
|
||||
// Axes only started stripping logs in 1.13
|
||||
if (item.identifier() == 1043 || item.identifier() == 1033 || item.identifier() == 1053 || item.identifier() == 1058 || item.identifier() == 1048 || item.identifier() == 1038 || item.identifier() == 1028) {
|
||||
container.setEmpty(StructuredDataKey.BLOCK_TRANSFORMER);
|
||||
}
|
||||
}
|
||||
if (serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
// Shovels only started creating dirt paths in 1.9
|
||||
if (item.identifier() == 1036 || item.identifier() == 1046 || item.identifier() == 1041 || item.identifier() == 1026 || item.identifier() == 1056 || item.identifier() == 1031 || item.identifier() == 1051) {
|
||||
container.setEmpty(StructuredDataKey.BLOCK_TRANSFORMER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void upgradeData(final StructuredDataContainer container) {
|
||||
container.remove(StructuredDataKey.MAP_COLOR);
|
||||
|
||||
|
||||
@@ -86,8 +86,10 @@ public class RegistryDataRewriter implements com.viaversion.viaversion.api.rewri
|
||||
|
||||
switch (key) {
|
||||
case "enchantment" -> updateEnchantments(connection, entries);
|
||||
case "trim_material" -> updateTrimMaterials(entries);
|
||||
case "jukebox_song" -> updateJukeboxSongs(entries);
|
||||
case "trim_material" -> updateTrimMaterials(connection, entries);
|
||||
case "jukebox_song" -> updateJukeboxSongs(connection, entries);
|
||||
case "trim_pattern", "instrument" -> updateTextComponents(connection, entries, "description");
|
||||
case "painting_variant" -> updateTextComponents(connection, entries, "title", "author");
|
||||
case "worldgen/biome" -> updateBiomes(entries);
|
||||
case "worldgen/block_state_provider" -> updateBlockStateProviders(entries);
|
||||
case "dimension_type" -> updateDimensionTypes(entries);
|
||||
@@ -291,6 +293,18 @@ public class RegistryDataRewriter implements com.viaversion.viaversion.api.rewri
|
||||
updateTextComponent(connection, tag, "tooltip");
|
||||
}
|
||||
|
||||
protected void updateTextComponents(final UserConnection connection, final RegistryEntry[] entries, final String... keys) {
|
||||
for (final RegistryEntry entry : entries) {
|
||||
if (!(entry.tag() instanceof final CompoundTag tag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (final String key : keys) {
|
||||
updateTextComponent(connection, tag, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateTextComponent(final UserConnection connection, @Nullable final CompoundTag tag, final String key) {
|
||||
if (tag != null && protocol.getComponentRewriter() != null) {
|
||||
protocol.getComponentRewriter().processTag(connection, tag.get(key));
|
||||
@@ -333,6 +347,7 @@ public class RegistryDataRewriter implements com.viaversion.viaversion.api.rewri
|
||||
}
|
||||
|
||||
final CompoundTag tag = (CompoundTag) entry.tag();
|
||||
updateTextComponent(connection, tag, "description");
|
||||
if (!Mappings.isFullIdentity(protocol.getMappingData().getFullItemMappings())) {
|
||||
updateItemList(tag.getListTag("supported_items", StringTag.class));
|
||||
updateItemList(tag.getListTag("primary_items", StringTag.class));
|
||||
@@ -365,7 +380,8 @@ public class RegistryDataRewriter implements com.viaversion.viaversion.api.rewri
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTrimMaterials(final RegistryEntry[] entries) {
|
||||
public void updateTrimMaterials(final UserConnection connection, final RegistryEntry[] entries) {
|
||||
updateTextComponents(connection, entries, "description");
|
||||
if (Mappings.isFullIdentity(protocol.getMappingData().getFullItemMappings())) {
|
||||
return;
|
||||
}
|
||||
@@ -384,7 +400,8 @@ public class RegistryDataRewriter implements com.viaversion.viaversion.api.rewri
|
||||
}
|
||||
}
|
||||
|
||||
public void updateJukeboxSongs(final RegistryEntry[] entries) {
|
||||
public void updateJukeboxSongs(final UserConnection connection, final RegistryEntry[] entries) {
|
||||
updateTextComponents(connection, entries, "description");
|
||||
// can be overridden
|
||||
}
|
||||
|
||||
@@ -454,6 +471,14 @@ public class RegistryDataRewriter implements com.viaversion.viaversion.api.rewri
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tag dripstoneParticle = TagUtil.getNamespacedTag(tag, "visual/default_dripstone_particle");
|
||||
if (dripstoneParticle instanceof CompoundTag modifierTag && modifierTag.contains("argument")) {
|
||||
dripstoneParticle = modifierTag.get("argument");
|
||||
}
|
||||
if (dripstoneParticle instanceof CompoundTag particle) {
|
||||
handleParticleData(particle);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNestedEffect(final CompoundTag effectsTag) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user