mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-03-12 06:29:22 +01:00
24w44a
This commit is contained in:
parent
dd660a2de0
commit
82c55b1d78
@ -87,6 +87,7 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
|
||||
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, "1.21-1.21.1", new SubVersionRange("1.21", 0, 1));
|
||||
public static final ProtocolVersion v1_21_2 = register(768, "1.21.2-1.21.3", new SubVersionRange("1.21", 2, 3));
|
||||
public static final ProtocolVersion v1_21_4 = register(769, 220, "1.21.4");
|
||||
public static final ProtocolVersion unknown = new ProtocolVersion(VersionType.SPECIAL, -1, -1, "UNKNOWN", null);
|
||||
|
||||
static {
|
||||
|
@ -193,6 +193,7 @@ public final class Types {
|
||||
|
||||
public static final BitSetType PROFILE_ACTIONS_ENUM1_19_3 = new BitSetType(6);
|
||||
public static final BitSetType PROFILE_ACTIONS_ENUM1_21_2 = new BitSetType(7);
|
||||
public static final BitSetType PROFILE_ACTIONS_ENUM1_21_4 = new BitSetType(8);
|
||||
|
||||
public static final ByteArrayType SIGNATURE_BYTES = new ByteArrayType(256);
|
||||
public static final BitSetType ACKNOWLEDGED_BIT_SET = new BitSetType(20);
|
||||
|
@ -29,7 +29,6 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
@ -148,12 +147,19 @@ public class ParticleType extends DynamicType<Particle> {
|
||||
public static final DataReader<Particle> COLOR = (buf, particle) -> {
|
||||
particle.add(Types.INT, Types.INT.readPrimitive(buf));
|
||||
};
|
||||
public static final DataReader<Particle> TRAIL = (buf, particle) -> {
|
||||
public static final DataReader<Particle> TRAIL1_21_2 = (buf, particle) -> {
|
||||
particle.add(Types.DOUBLE, Types.DOUBLE.readPrimitive(buf)); // Target X
|
||||
particle.add(Types.DOUBLE, Types.DOUBLE.readPrimitive(buf)); // Target Y
|
||||
particle.add(Types.DOUBLE, Types.DOUBLE.readPrimitive(buf)); // Target Z
|
||||
particle.add(Types.INT, Types.INT.readPrimitive(buf)); // Color
|
||||
};
|
||||
public static final DataReader<Particle> TRAIL1_21_4 = (buf, particle) -> {
|
||||
particle.add(Types.DOUBLE, Types.DOUBLE.readPrimitive(buf)); // Target X
|
||||
particle.add(Types.DOUBLE, Types.DOUBLE.readPrimitive(buf)); // Target Y
|
||||
particle.add(Types.DOUBLE, Types.DOUBLE.readPrimitive(buf)); // Target Z
|
||||
particle.add(Types.INT, Types.INT.readPrimitive(buf)); // Color
|
||||
particle.add(Types.VAR_INT, Types.VAR_INT.readPrimitive(buf)); // Duration
|
||||
};
|
||||
|
||||
public static DataReader<Particle> item(Type<Item> item) {
|
||||
return (buf, particle) -> particle.add(item, item.read(buf));
|
||||
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.type.types.version;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredData;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_21;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||
import com.viaversion.viaversion.api.type.types.entitydata.EntityDataListType;
|
||||
import com.viaversion.viaversion.api.type.types.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.types.item.ItemCostType1_20_5;
|
||||
import com.viaversion.viaversion.api.type.types.item.ItemType1_20_5;
|
||||
import com.viaversion.viaversion.api.type.types.item.StructuredDataType;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
import java.util.List;
|
||||
|
||||
// Most of these are only safe to use after protocol loading
|
||||
public final class Types1_21_4 {
|
||||
|
||||
public static final StructuredDataType STRUCTURED_DATA = new StructuredDataType();
|
||||
public static final Type<StructuredData<?>[]> STRUCTURED_DATA_ARRAY = new ArrayType<>(STRUCTURED_DATA);
|
||||
public static final ItemType1_20_5 ITEM = new ItemType1_20_5(STRUCTURED_DATA);
|
||||
public static final Type<Item> OPTIONAL_ITEM = ITEM.new OptionalItemType(); // Optional as in boolean prefixed, not via the amount
|
||||
public static final Type<Item[]> ITEM_ARRAY = new ArrayType<>(ITEM);
|
||||
public static final Type<Item> ITEM_COST = new ItemCostType1_20_5(STRUCTURED_DATA_ARRAY);
|
||||
public static final Type<Item> OPTIONAL_ITEM_COST = new ItemCostType1_20_5.OptionalItemCostType(ITEM_COST);
|
||||
|
||||
public static final ParticleType PARTICLE = new ParticleType();
|
||||
public static final ArrayType<Particle> PARTICLES = new ArrayType<>(PARTICLE);
|
||||
public static final EntityDataTypes1_21 ENTITY_DATA_TYPES = new EntityDataTypes1_21(ITEM, PARTICLE, PARTICLES);
|
||||
public static final Type<EntityData> ENTITY_DATA = new EntityDataType(ENTITY_DATA_TYPES);
|
||||
public static final Type<List<EntityData>> ENTITY_DATA_LIST = new EntityDataListType(ENTITY_DATA);
|
||||
}
|
@ -76,6 +76,7 @@ import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.Protocol1_20_2To1_20_
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.Protocol1_20_3To1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21;
|
||||
import com.viaversion.viaversion.protocols.v1_20to1_20_2.Protocol1_20To1_20_2;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.Protocol1_21_2To1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.Protocol1_21To1_21_2;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9;
|
||||
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.Protocol1_9_1To1_9_3;
|
||||
@ -194,6 +195,7 @@ public class ProtocolManagerImpl implements ProtocolManager {
|
||||
|
||||
registerProtocol(new Protocol1_20_5To1_21(), ProtocolVersion.v1_21, ProtocolVersion.v1_20_5);
|
||||
registerProtocol(new Protocol1_21To1_21_2(), ProtocolVersion.v1_21_2, ProtocolVersion.v1_21);
|
||||
registerProtocol(new Protocol1_21_2To1_21_4(), ProtocolVersion.v1_21_4, ProtocolVersion.v1_21_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,7 +80,7 @@ final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1_21, Cl
|
||||
componentRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21.PLAYER_COMBAT_KILL);
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_21.SYSTEM_CHAT);
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_21.DISGUISED_CHAT);
|
||||
componentRewriter.registerPlayerInfoUpdate1_21_2(ClientboundPackets1_21.PLAYER_INFO_UPDATE);
|
||||
componentRewriter.registerPlayerInfoUpdate1_21_4(ClientboundPackets1_21.PLAYER_INFO_UPDATE);
|
||||
componentRewriter.registerPing();
|
||||
|
||||
// If needed for any particle, item, or block changes. Extend ParticleRewriter for particle serializer changes
|
||||
@ -126,7 +126,7 @@ final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1_21, Cl
|
||||
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
|
||||
.reader("shriek", ParticleType.Readers.SHRIEK)
|
||||
.reader("entity_effect", ParticleType.Readers.COLOR)
|
||||
.reader("trail", ParticleType.Readers.TRAIL)
|
||||
.reader("trail", ParticleType.Readers.TRAIL1_21_4)
|
||||
.reader("item", ParticleType.Readers.item(itemRewriter.mappedItemType()));*/
|
||||
|
||||
super.onMappingDataLoaded(); // Calls load methods on rewriters. Last in case the rewriters access the above filled data
|
||||
|
@ -18,9 +18,10 @@
|
||||
package com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPacket1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ServerboundPacket1_21_2;
|
||||
|
||||
public enum ServerboundConfigurationPackets1_20_5 implements ServerboundPacket1_20_5, ServerboundPacket1_21_2 {
|
||||
public enum ServerboundConfigurationPackets1_20_5 implements ServerboundPacket1_20_5, ServerboundPacket1_21_2, ServerboundPacket1_21_4 {
|
||||
|
||||
CLIENT_INFORMATION, // 0x00
|
||||
COOKIE_RESPONSE, // 0x01
|
||||
|
@ -0,0 +1,237 @@
|
||||
/*
|
||||
* 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_21_2to1_21_4;
|
||||
|
||||
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.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_2;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundConfigurationPackets1_20_5;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPacket1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPackets1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.rewriter.BlockItemPacketRewriter1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.rewriter.ComponentRewriter1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.rewriter.EntityPacketRewriter1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.rewriter.ParticleRewriter1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ServerboundPacket1_21_2;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ServerboundPackets1_21_2;
|
||||
import com.viaversion.viaversion.rewriter.AttributeRewriter;
|
||||
import com.viaversion.viaversion.rewriter.ParticleRewriter;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import java.util.BitSet;
|
||||
|
||||
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
|
||||
|
||||
public final class Protocol1_21_2To1_21_4 extends AbstractProtocol<ClientboundPacket1_21_2, ClientboundPacket1_21_2, ServerboundPacket1_21_2, ServerboundPacket1_21_4> {
|
||||
|
||||
public static final MappingData MAPPINGS = new MappingDataBase("1.21.2", "1.21.4");
|
||||
private final EntityPacketRewriter1_21_4 entityRewriter = new EntityPacketRewriter1_21_4(this);
|
||||
private final BlockItemPacketRewriter1_21_4 itemRewriter = new BlockItemPacketRewriter1_21_4(this);
|
||||
private final ParticleRewriter<ClientboundPacket1_21_2> particleRewriter = new ParticleRewriter1_21_4(this);
|
||||
private final TagRewriter<ClientboundPacket1_21_2> tagRewriter = new TagRewriter<>(this);
|
||||
private final ComponentRewriter1_21_4 componentRewriter = new ComponentRewriter1_21_4(this);
|
||||
|
||||
public Protocol1_21_2To1_21_4() {
|
||||
super(ClientboundPacket1_21_2.class, ClientboundPacket1_21_2.class, ServerboundPacket1_21_2.class, ServerboundPacket1_21_4.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_21_2.UPDATE_TAGS);
|
||||
tagRewriter.registerGeneric(ClientboundConfigurationPackets1_21.UPDATE_TAGS);
|
||||
|
||||
componentRewriter.registerOpenScreen(ClientboundPackets1_21_2.OPEN_SCREEN);
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_ACTION_BAR_TEXT);
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_TITLE_TEXT);
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_SUBTITLE_TEXT);
|
||||
componentRewriter.registerBossEvent(ClientboundPackets1_21_2.BOSS_EVENT);
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.DISCONNECT);
|
||||
componentRewriter.registerTabList(ClientboundPackets1_21_2.TAB_LIST);
|
||||
componentRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21_2.PLAYER_COMBAT_KILL);
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.SYSTEM_CHAT);
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_21_2.DISGUISED_CHAT);
|
||||
componentRewriter.registerPing();
|
||||
|
||||
particleRewriter.registerExplode1_21_2(ClientboundPackets1_21_2.EXPLODE);
|
||||
registerClientbound(ClientboundPackets1_21_2.LEVEL_PARTICLES, wrapper -> {
|
||||
wrapper.passthrough(Types.BOOLEAN); // Override limiter
|
||||
wrapper.write(Types.BOOLEAN, false); // Always show
|
||||
wrapper.passthrough(Types.DOUBLE); // X
|
||||
wrapper.passthrough(Types.DOUBLE); // Y
|
||||
wrapper.passthrough(Types.DOUBLE); // Z
|
||||
wrapper.passthrough(Types.FLOAT); // Offset X
|
||||
wrapper.passthrough(Types.FLOAT); // Offset Y
|
||||
wrapper.passthrough(Types.FLOAT); // Offset Z
|
||||
wrapper.passthrough(Types.FLOAT); // Particle Data
|
||||
wrapper.passthrough(Types.INT); // Particle Count
|
||||
|
||||
final Particle particle = wrapper.passthroughAndMap(Types1_21_2.PARTICLE, Types1_21_4.PARTICLE);
|
||||
particleRewriter.rewriteParticle(wrapper.user(), particle);
|
||||
});
|
||||
|
||||
final SoundRewriter<ClientboundPacket1_21_2> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.registerSound1_19_3(ClientboundPackets1_21_2.SOUND);
|
||||
soundRewriter.registerSound1_19_3(ClientboundPackets1_21_2.SOUND_ENTITY);
|
||||
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_21_2.AWARD_STATS);
|
||||
new AttributeRewriter<>(this).register1_21(ClientboundPackets1_21_2.UPDATE_ATTRIBUTES);
|
||||
|
||||
registerClientbound(ClientboundPackets1_21_2.PLAYER_INFO_UPDATE, wrapper -> {
|
||||
// Added "show hat" - true by default, keep it like that
|
||||
final BitSet actions = wrapper.passthroughAndMap(Types.PROFILE_ACTIONS_ENUM1_21_2, Types.PROFILE_ACTIONS_ENUM1_21_4);
|
||||
if (!actions.get(5)) { // Update display name
|
||||
return;
|
||||
}
|
||||
|
||||
final int entries = wrapper.passthrough(Types.VAR_INT);
|
||||
for (int i = 0; i < entries; i++) {
|
||||
wrapper.passthrough(Types.UUID);
|
||||
if (actions.get(0)) {
|
||||
wrapper.passthrough(Types.STRING); // Player Name
|
||||
|
||||
final int properties = wrapper.passthrough(Types.VAR_INT);
|
||||
for (int j = 0; j < properties; j++) {
|
||||
wrapper.passthrough(Types.STRING); // Name
|
||||
wrapper.passthrough(Types.STRING); // Value
|
||||
wrapper.passthrough(Types.OPTIONAL_STRING); // Signature
|
||||
}
|
||||
}
|
||||
if (actions.get(1) && wrapper.passthrough(Types.BOOLEAN)) {
|
||||
wrapper.passthrough(Types.UUID); // Session UUID
|
||||
wrapper.passthrough(Types.PROFILE_KEY);
|
||||
}
|
||||
if (actions.get(2)) {
|
||||
wrapper.passthrough(Types.VAR_INT); // Gamemode
|
||||
}
|
||||
if (actions.get(3)) {
|
||||
wrapper.passthrough(Types.BOOLEAN); // Listed
|
||||
}
|
||||
if (actions.get(4)) {
|
||||
wrapper.passthrough(Types.VAR_INT); // Latency
|
||||
}
|
||||
componentRewriter.processTag(wrapper.user(), wrapper.passthrough(Types.OPTIONAL_TAG));
|
||||
if (actions.get(6)) {
|
||||
wrapper.passthrough(Types.VAR_INT); // List order
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
Types1_21_4.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("block_marker", ParticleType.Readers.BLOCK)
|
||||
.reader("dust_pillar", ParticleType.Readers.BLOCK)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("block_crumble", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST1_21_2)
|
||||
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION1_21_2)
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION1_20_3)
|
||||
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
|
||||
.reader("shriek", ParticleType.Readers.SHRIEK)
|
||||
.reader("entity_effect", ParticleType.Readers.COLOR)
|
||||
.reader("trail", ParticleType.Readers.TRAIL1_21_4)
|
||||
.reader("item", ParticleType.Readers.item(itemRewriter.mappedItemType()));
|
||||
// TODO Nothing not yet, keep since it'll probably be needed
|
||||
Types1_21_4.STRUCTURED_DATA.filler(this).add(StructuredDataKey.CUSTOM_DATA, StructuredDataKey.MAX_STACK_SIZE, StructuredDataKey.MAX_DAMAGE,
|
||||
StructuredDataKey.UNBREAKABLE, StructuredDataKey.RARITY, StructuredDataKey.HIDE_TOOLTIP, StructuredDataKey.DAMAGE_RESISTANT,
|
||||
StructuredDataKey.CUSTOM_NAME, StructuredDataKey.LORE, StructuredDataKey.ENCHANTMENTS, StructuredDataKey.CAN_PLACE_ON,
|
||||
StructuredDataKey.CAN_BREAK, StructuredDataKey.CUSTOM_MODEL_DATA, StructuredDataKey.HIDE_ADDITIONAL_TOOLTIP,
|
||||
StructuredDataKey.REPAIR_COST, StructuredDataKey.CREATIVE_SLOT_LOCK, StructuredDataKey.ENCHANTMENT_GLINT_OVERRIDE,
|
||||
StructuredDataKey.INTANGIBLE_PROJECTILE, StructuredDataKey.STORED_ENCHANTMENTS, StructuredDataKey.DYED_COLOR,
|
||||
StructuredDataKey.MAP_COLOR, StructuredDataKey.MAP_ID, StructuredDataKey.MAP_DECORATIONS, StructuredDataKey.MAP_POST_PROCESSING,
|
||||
StructuredDataKey.POTION_CONTENTS1_21_2, StructuredDataKey.SUSPICIOUS_STEW_EFFECTS, StructuredDataKey.WRITABLE_BOOK_CONTENT,
|
||||
StructuredDataKey.WRITTEN_BOOK_CONTENT, StructuredDataKey.TRIM, StructuredDataKey.DEBUG_STICK_STATE, StructuredDataKey.ENTITY_DATA,
|
||||
StructuredDataKey.BUCKET_ENTITY_DATA, StructuredDataKey.BLOCK_ENTITY_DATA, StructuredDataKey.INSTRUMENT1_21_2,
|
||||
StructuredDataKey.RECIPES, StructuredDataKey.LODESTONE_TRACKER, StructuredDataKey.FIREWORK_EXPLOSION, StructuredDataKey.FIREWORKS,
|
||||
StructuredDataKey.PROFILE, StructuredDataKey.NOTE_BLOCK_SOUND, StructuredDataKey.BANNER_PATTERNS, StructuredDataKey.BASE_COLOR,
|
||||
StructuredDataKey.POT_DECORATIONS, StructuredDataKey.BLOCK_STATE, StructuredDataKey.BEES, StructuredDataKey.LOCK,
|
||||
StructuredDataKey.CONTAINER_LOOT, StructuredDataKey.TOOL, StructuredDataKey.ITEM_NAME, StructuredDataKey.OMINOUS_BOTTLE_AMPLIFIER,
|
||||
StructuredDataKey.FOOD1_21_2, StructuredDataKey.JUKEBOX_PLAYABLE, StructuredDataKey.ATTRIBUTE_MODIFIERS1_21,
|
||||
StructuredDataKey.REPAIRABLE, StructuredDataKey.ENCHANTABLE, StructuredDataKey.CONSUMABLE1_21_2,
|
||||
StructuredDataKey.USE_COOLDOWN, StructuredDataKey.DAMAGE, StructuredDataKey.EQUIPPABLE, StructuredDataKey.ITEM_MODEL,
|
||||
StructuredDataKey.GLIDER, StructuredDataKey.TOOLTIP_STYLE, StructuredDataKey.DEATH_PROTECTION,
|
||||
// Volatile thanks to containing item
|
||||
StructuredDataKey.CHARGED_PROJECTILES1_21_2, StructuredDataKey.BUNDLE_CONTENTS1_21_2, StructuredDataKey.CONTAINER1_21_2, StructuredDataKey.USE_REMAINDER);
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final UserConnection connection) {
|
||||
addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_2.PLAYER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingData getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPacketRewriter1_21_4 getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItemPacketRewriter1_21_4 getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleRewriter<ClientboundPacket1_21_2> getParticleRewriter() {
|
||||
return particleRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagRewriter<ClientboundPacket1_21_2> getTagRewriter() {
|
||||
return tagRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentRewriter getComponentRewriter() {
|
||||
return componentRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PacketTypesProvider<ClientboundPacket1_21_2, ClientboundPacket1_21_2, ServerboundPacket1_21_2, ServerboundPacket1_21_4> createPacketTypesProvider() {
|
||||
return new SimplePacketTypesProvider<>(
|
||||
packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_21_2.class, ClientboundConfigurationPackets1_21.class),
|
||||
packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_21_2.class, ClientboundConfigurationPackets1_21.class),
|
||||
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_21_2.class, ServerboundConfigurationPackets1_20_5.class),
|
||||
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_21_4.class, ServerboundConfigurationPackets1_20_5.class)
|
||||
);
|
||||
}
|
||||
}
|
@ -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_21_2to1_21_4.packet;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
|
||||
public interface ServerboundPacket1_21_4 extends ServerboundPacketType {
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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_21_2to1_21_4.packet;
|
||||
|
||||
public enum ServerboundPackets1_21_4 implements ServerboundPacket1_21_4 {
|
||||
|
||||
ACCEPT_TELEPORTATION, // 0x00
|
||||
BLOCK_ENTITY_TAG_QUERY, // 0x01
|
||||
BUNDLE_ITEM_SELECTED, // 0x02
|
||||
CHANGE_DIFFICULTY, // 0x03
|
||||
CHAT_ACK, // 0x04
|
||||
CHAT_COMMAND, // 0x05
|
||||
CHAT_COMMAND_SIGNED, // 0x06
|
||||
CHAT, // 0x07
|
||||
CHAT_SESSION_UPDATE, // 0x08
|
||||
CHUNK_BATCH_RECEIVED, // 0x09
|
||||
CLIENT_COMMAND, // 0x0A
|
||||
CLIENT_TICK_END, // 0x0B
|
||||
CLIENT_INFORMATION, // 0x0C
|
||||
COMMAND_SUGGESTION, // 0x0D
|
||||
CONFIGURATION_ACKNOWLEDGED, // 0x0E
|
||||
CONTAINER_BUTTON_CLICK, // 0x0F
|
||||
CONTAINER_CLICK, // 0x10
|
||||
CONTAINER_CLOSE, // 0x11
|
||||
CONTAINER_SLOT_STATE_CHANGED, // 0x12
|
||||
COOKIE_RESPONSE, // 0x13
|
||||
CUSTOM_PAYLOAD, // 0x14
|
||||
DEBUG_SAMPLE_SUBSCRIPTION, // 0x15
|
||||
EDIT_BOOK, // 0x16
|
||||
ENTITY_TAG_QUERY, // 0x17
|
||||
INTERACT, // 0x18
|
||||
JIGSAW_GENERATE, // 0x19
|
||||
KEEP_ALIVE, // 0x1A
|
||||
LOCK_DIFFICULTY, // 0x1B
|
||||
MOVE_PLAYER_POS, // 0x1C
|
||||
MOVE_PLAYER_POS_ROT, // 0x1D
|
||||
MOVE_PLAYER_ROT, // 0x1E
|
||||
MOVE_PLAYER_STATUS_ONLY, // 0x1F
|
||||
MOVE_VEHICLE, // 0x20
|
||||
PADDLE_BOAT, // 0x21
|
||||
PICK_ITEM_FROM_BLOCK, // 0x22
|
||||
PICK_ITEM_FROM_ENTITY, // 0x22
|
||||
PING_REQUEST, // 0x23
|
||||
PLACE_RECIPE, // 0x24
|
||||
PLAYER_ABILITIES, // 0x25
|
||||
PLAYER_ACTION, // 0x26
|
||||
PLAYER_COMMAND, // 0x27
|
||||
PLAYER_INPUT, // 0x28
|
||||
PONG, // 0x29
|
||||
RECIPE_BOOK_CHANGE_SETTINGS, // 0x2A
|
||||
RECIPE_BOOK_SEEN_RECIPE, // 0x2B
|
||||
RENAME_ITEM, // 0x2C
|
||||
RESOURCE_PACK, // 0x2D
|
||||
SEEN_ADVANCEMENTS, // 0x2E
|
||||
SELECT_TRADE, // 0x2F
|
||||
SET_BEACON, // 0x30
|
||||
SET_CARRIED_ITEM, // 0x31
|
||||
SET_COMMAND_BLOCK, // 0x32
|
||||
SET_COMMAND_MINECART, // 0x33
|
||||
SET_CREATIVE_MODE_SLOT, // 0x34
|
||||
SET_JIGSAW_BLOCK, // 0x35
|
||||
SET_STRUCTURE_BLOCK, // 0x36
|
||||
SIGN_UPDATE, // 0x37
|
||||
SWING, // 0x38
|
||||
TELEPORT_TO_ENTITY, // 0x39
|
||||
USE_ITEM_ON, // 0x3A
|
||||
USE_ITEM; // 0x3B
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name();
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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_21_2to1_21_4.rewriter;
|
||||
|
||||
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.version.Types1_21_2;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.Protocol1_21_2To1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPacket1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPackets1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.rewriter.RecipeDisplayRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
|
||||
|
||||
public final class BlockItemPacketRewriter1_21_4 extends StructuredItemRewriter<ClientboundPacket1_21_2, ServerboundPacket1_21_4, Protocol1_21_2To1_21_4> {
|
||||
|
||||
public BlockItemPacketRewriter1_21_4(final Protocol1_21_2To1_21_4 protocol) {
|
||||
super(protocol,
|
||||
Types1_21_2.ITEM, Types1_21_2.ITEM_ARRAY, Types1_21_4.ITEM, Types1_21_4.ITEM_ARRAY,
|
||||
Types1_21_2.ITEM_COST, Types1_21_2.OPTIONAL_ITEM_COST, Types1_21_4.ITEM_COST, Types1_21_4.OPTIONAL_ITEM_COST
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
final BlockRewriter<ClientboundPacket1_21_2> blockRewriter = BlockRewriter.for1_20_2(protocol);
|
||||
blockRewriter.registerBlockEvent(ClientboundPackets1_21_2.BLOCK_EVENT);
|
||||
blockRewriter.registerBlockUpdate(ClientboundPackets1_21_2.BLOCK_UPDATE);
|
||||
blockRewriter.registerSectionBlocksUpdate1_20(ClientboundPackets1_21_2.SECTION_BLOCKS_UPDATE);
|
||||
blockRewriter.registerLevelEvent1_21(ClientboundPackets1_21_2.LEVEL_EVENT, 2001);
|
||||
blockRewriter.registerLevelChunk1_19(ClientboundPackets1_21_2.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_20_2::new);
|
||||
blockRewriter.registerBlockEntityData(ClientboundPackets1_21_2.BLOCK_ENTITY_DATA);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_21_2.SET_HELD_SLOT, wrapper -> {
|
||||
final byte slot = wrapper.read(Types.BYTE);
|
||||
wrapper.write(Types.VAR_INT, (int) slot);
|
||||
});
|
||||
|
||||
protocol.cancelServerbound(ServerboundPackets1_21_4.PICK_ITEM_FROM_BLOCK);
|
||||
protocol.cancelServerbound(ServerboundPackets1_21_4.PICK_ITEM_FROM_ENTITY);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_21_2.SET_CURSOR_ITEM, this::passthroughClientboundItem);
|
||||
registerCooldown1_21_2(ClientboundPackets1_21_2.COOLDOWN);
|
||||
registerSetContent1_21_2(ClientboundPackets1_21_2.CONTAINER_SET_CONTENT);
|
||||
registerSetSlot1_21_2(ClientboundPackets1_21_2.CONTAINER_SET_SLOT);
|
||||
registerAdvancements1_20_3(ClientboundPackets1_21_2.UPDATE_ADVANCEMENTS);
|
||||
registerSetEquipment(ClientboundPackets1_21_2.SET_EQUIPMENT);
|
||||
registerContainerClick1_21_2(ServerboundPackets1_21_4.CONTAINER_CLICK);
|
||||
registerMerchantOffers1_20_5(ClientboundPackets1_21_2.MERCHANT_OFFERS);
|
||||
registerSetCreativeModeSlot(ServerboundPackets1_21_4.SET_CREATIVE_MODE_SLOT);
|
||||
|
||||
final RecipeDisplayRewriter<ClientboundPacket1_21_2> recipeRewriter = new RecipeDisplayRewriter<>(protocol);
|
||||
recipeRewriter.registerUpdateRecipes(ClientboundPackets1_21_2.UPDATE_RECIPES);
|
||||
recipeRewriter.registerRecipeBookAdd(ClientboundPackets1_21_2.RECIPE_BOOK_ADD);
|
||||
recipeRewriter.registerPlaceGhostRecipe(ClientboundPackets1_21_2.PLACE_GHOST_RECIPE);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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_21_2to1_21_4.rewriter;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.Protocol1_21_2To1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.util.SerializerVersion;
|
||||
|
||||
public final class ComponentRewriter1_21_4 extends ComponentRewriter<ClientboundPacket1_21_2> {
|
||||
|
||||
public ComponentRewriter1_21_4(final Protocol1_21_2To1_21_4 protocol) {
|
||||
super(protocol, ReadType.NBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleShowItem(final UserConnection connection, final CompoundTag itemTag, final CompoundTag componentsTag) {
|
||||
super.handleShowItem(connection, itemTag, componentsTag);
|
||||
if (componentsTag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove or update data from componentsTag
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SerializerVersion inputSerializerVersion() {
|
||||
return SerializerVersion.V1_20_5;
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* 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_21_2to1_21_4.rewriter;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_2;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.Protocol1_21_2To1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.rewriter.RegistryDataRewriter;
|
||||
import com.viaversion.viaversion.util.Key;
|
||||
|
||||
public final class EntityPacketRewriter1_21_4 extends EntityRewriter<ClientboundPacket1_21_2, Protocol1_21_2To1_21_4> {
|
||||
|
||||
public EntityPacketRewriter1_21_4(final Protocol1_21_2To1_21_4 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
registerTrackerWithData1_19(ClientboundPackets1_21_2.ADD_ENTITY, EntityTypes1_21_2.FALLING_BLOCK);
|
||||
registerSetEntityData(ClientboundPackets1_21_2.SET_ENTITY_DATA, Types1_21_2.ENTITY_DATA_LIST, Types1_21_4.ENTITY_DATA_LIST); // Specify old and new entity data list if changed
|
||||
registerRemoveEntities(ClientboundPackets1_21_2.REMOVE_ENTITIES);
|
||||
|
||||
final RegistryDataRewriter registryDataRewriter = new RegistryDataRewriter(protocol) {
|
||||
@Override
|
||||
public RegistryEntry[] handle(final UserConnection connection, final String key, final RegistryEntry[] entries) {
|
||||
if (Key.stripMinecraftNamespace(key).equals("worldgen/biome")) {
|
||||
for (final RegistryEntry entry : entries) {
|
||||
if (entry.tag() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final CompoundTag effectsTag = ((CompoundTag) entry.tag()).getCompoundTag("effects");
|
||||
final CompoundTag musicTag = effectsTag.getCompoundTag("music");
|
||||
if (musicTag == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Wrap music
|
||||
final ListTag<CompoundTag> weightedMusicTags = new ListTag<>(CompoundTag.class);
|
||||
final CompoundTag weightedMusicTag = new CompoundTag();
|
||||
weightedMusicTag.put("data", musicTag);
|
||||
weightedMusicTag.putInt("weight", 1);
|
||||
weightedMusicTags.add(weightedMusicTag);
|
||||
effectsTag.put("music", weightedMusicTags);
|
||||
}
|
||||
}
|
||||
|
||||
return super.handle(connection, key, entries);
|
||||
}
|
||||
};
|
||||
protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, registryDataRewriter::handle);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_21_2.LOGIN, wrapper -> {
|
||||
final int entityId = wrapper.passthrough(Types.INT); // Entity id
|
||||
wrapper.passthrough(Types.BOOLEAN); // Hardcore
|
||||
wrapper.passthrough(Types.STRING_ARRAY); // World List
|
||||
wrapper.passthrough(Types.VAR_INT); // Max players
|
||||
wrapper.passthrough(Types.VAR_INT); // View distance
|
||||
wrapper.passthrough(Types.VAR_INT); // Simulation distance
|
||||
wrapper.passthrough(Types.BOOLEAN); // Reduced debug info
|
||||
wrapper.passthrough(Types.BOOLEAN); // Show death screen
|
||||
wrapper.passthrough(Types.BOOLEAN); // Limited crafting
|
||||
|
||||
final int dimensionId = wrapper.passthrough(Types.VAR_INT);
|
||||
final String world = wrapper.passthrough(Types.STRING);
|
||||
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world);
|
||||
|
||||
trackPlayer(wrapper.user(), entityId);
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_21_2.RESPAWN, wrapper -> {
|
||||
final int dimensionId = wrapper.passthrough(Types.VAR_INT);
|
||||
final String world = wrapper.passthrough(Types.STRING);
|
||||
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world); // Tracks world height and name for chunk data and entity (un)tracking
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().mapDataType(Types1_21_4.ENTITY_DATA_TYPES::byId);
|
||||
|
||||
registerEntityDataTypeHandler(
|
||||
Types1_21_4.ENTITY_DATA_TYPES.itemType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.blockStateType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.optionalBlockStateType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.particleType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.particlesType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.componentType,
|
||||
Types1_21_4.ENTITY_DATA_TYPES.optionalComponentType
|
||||
);
|
||||
registerBlockStateHandler(EntityTypes1_21_2.ABSTRACT_MINECART, 11);
|
||||
|
||||
filter().type(EntityTypes1_21_2.CREAKING_TRANSIENT).addIndex(18); // Is tearing down
|
||||
filter().type(EntityTypes1_21_2.SALMON).index(17).handler((data, event) -> {
|
||||
final String type = event.value();
|
||||
final int typeId = switch (type) {
|
||||
case "small" -> 0;
|
||||
case "large" -> 2;
|
||||
default -> 1; // medium
|
||||
};
|
||||
event.setTypeAndValue(Types1_21_4.ENTITY_DATA_TYPES.varIntType, typeId);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(final int type) {
|
||||
return EntityTypes1_21_2.getTypeFromId(type);
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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_21_2to1_21_4.rewriter;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
|
||||
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
|
||||
import com.viaversion.viaversion.rewriter.ParticleRewriter;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public final class ParticleRewriter1_21_4 extends ParticleRewriter<ClientboundPacket1_21_2> {
|
||||
|
||||
public ParticleRewriter1_21_4(final Protocol<ClientboundPacket1_21_2, ?, ?, ?> protocol) {
|
||||
super(protocol, Types1_21_2.PARTICLE, Types1_21_4.PARTICLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rewriteParticle(final UserConnection connection, final Particle particle) {
|
||||
super.rewriteParticle(connection, particle);
|
||||
|
||||
final String identifier = protocol.getMappingData().getParticleMappings().mappedIdentifier(particle.id());
|
||||
if (identifier.equals("minecraft:trail")) {
|
||||
// Duration
|
||||
particle.add(Types.VAR_INT, ThreadLocalRandom.current().nextInt(40) + 10);
|
||||
}
|
||||
}
|
||||
}
|
@ -204,7 +204,7 @@ public final class Protocol1_21To1_21_2 extends AbstractProtocol<ClientboundPack
|
||||
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
|
||||
.reader("shriek", ParticleType.Readers.SHRIEK)
|
||||
.reader("entity_effect", ParticleType.Readers.COLOR)
|
||||
.reader("trail", ParticleType.Readers.TRAIL)
|
||||
.reader("trail", ParticleType.Readers.TRAIL1_21_2)
|
||||
.reader("item", ParticleType.Readers.item(Types1_21_2.ITEM));
|
||||
Types1_21_2.STRUCTURED_DATA.filler(this).add(StructuredDataKey.CUSTOM_DATA, StructuredDataKey.MAX_STACK_SIZE, StructuredDataKey.MAX_DAMAGE,
|
||||
StructuredDataKey.UNBREAKABLE, StructuredDataKey.RARITY, StructuredDataKey.HIDE_TOOLTIP, StructuredDataKey.DAMAGE_RESISTANT,
|
||||
|
@ -165,9 +165,9 @@ public class ComponentRewriter<C extends ClientboundPacketType> implements com.v
|
||||
});
|
||||
}
|
||||
|
||||
public void registerPlayerInfoUpdate1_21_2(final C packetType) {
|
||||
public void registerPlayerInfoUpdate1_21_4(final C packetType) {
|
||||
protocol.registerClientbound(packetType, wrapper -> {
|
||||
final BitSet actions = wrapper.passthrough(Types.PROFILE_ACTIONS_ENUM1_21_2);
|
||||
final BitSet actions = wrapper.passthrough(Types.PROFILE_ACTIONS_ENUM1_21_4);
|
||||
if (!actions.get(5)) { // Update display name
|
||||
return;
|
||||
}
|
||||
@ -204,6 +204,9 @@ public class ComponentRewriter<C extends ClientboundPacketType> implements com.v
|
||||
if (actions.get(6)) {
|
||||
wrapper.passthrough(Types.VAR_INT); // List order
|
||||
}
|
||||
if (actions.get(7)) {
|
||||
wrapper.passthrough(Types.BOOLEAN); // Show hat
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -115,7 +115,25 @@ public class ParticleRewriter<C extends ClientboundPacketType> implements com.vi
|
||||
|
||||
public void registerLevelParticles1_20_5(final C packetType) {
|
||||
protocol.registerClientbound(packetType, wrapper -> {
|
||||
wrapper.passthrough(Types.BOOLEAN); // Long Distance
|
||||
wrapper.passthrough(Types.BOOLEAN); // Override limiter
|
||||
wrapper.passthrough(Types.DOUBLE); // X
|
||||
wrapper.passthrough(Types.DOUBLE); // Y
|
||||
wrapper.passthrough(Types.DOUBLE); // Z
|
||||
wrapper.passthrough(Types.FLOAT); // Offset X
|
||||
wrapper.passthrough(Types.FLOAT); // Offset Y
|
||||
wrapper.passthrough(Types.FLOAT); // Offset Z
|
||||
wrapper.passthrough(Types.FLOAT); // Particle Data
|
||||
wrapper.passthrough(Types.INT); // Particle Count
|
||||
|
||||
final Particle particle = wrapper.passthroughAndMap(particleType, mappedParticleType);
|
||||
rewriteParticle(wrapper.user(), particle);
|
||||
});
|
||||
}
|
||||
|
||||
public void registerLevelParticles1_21_4(final C packetType) {
|
||||
protocol.registerClientbound(packetType, wrapper -> {
|
||||
wrapper.passthrough(Types.BOOLEAN); // Override limiter
|
||||
wrapper.passthrough(Types.BOOLEAN); // Always show
|
||||
wrapper.passthrough(Types.DOUBLE); // X
|
||||
wrapper.passthrough(Types.DOUBLE); // Y
|
||||
wrapper.passthrough(Types.DOUBLE); // Z
|
||||
|
@ -94,6 +94,8 @@ public class RecipeDisplayRewriter<C extends ClientboundPacketType> {
|
||||
handleSlotDisplay(wrapper); // Fuel
|
||||
handleSlotDisplay(wrapper); // Result
|
||||
handleSlotDisplay(wrapper); // Crafting station
|
||||
wrapper.passthrough(Types.VAR_INT); // Duration
|
||||
wrapper.passthrough(Types.FLOAT); // Experience
|
||||
}
|
||||
|
||||
protected void handleStoneCutter(final PacketWrapper wrapper) {
|
||||
@ -165,7 +167,7 @@ public class RecipeDisplayRewriter<C extends ClientboundPacketType> {
|
||||
}
|
||||
|
||||
protected void handleItemId(final PacketWrapper wrapper) {
|
||||
final int id = wrapper.passthrough(Types.VAR_INT);
|
||||
final int id = wrapper.read(Types.VAR_INT);
|
||||
wrapper.write(Types.VAR_INT, rewriteItemId(id));
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
|
||||
projectVersion=5.1.2-SNAPSHOT
|
||||
projectVersion=5.2.0-SNAPSHOT
|
||||
|
||||
# Smile emoji
|
||||
mcVersions=1.21.3,1.21.2,1.21.1,1.21,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
|
||||
|
Loading…
Reference in New Issue
Block a user