2023-03-22 18:49:18 +01:00
|
|
|
/*
|
|
|
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
2024-01-01 12:39:45 +01:00
|
|
|
* Copyright (C) 2016-2024 ViaVersion and contributors
|
2023-03-22 18:49:18 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package com.viaversion.viaversion.protocols.protocol1_20to1_19_4;
|
|
|
|
|
|
|
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
|
|
import com.viaversion.viaversion.api.data.MappingData;
|
|
|
|
import com.viaversion.viaversion.api.data.MappingDataBase;
|
2023-10-19 01:28:12 +02:00
|
|
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
|
2023-03-22 18:49:18 +01:00
|
|
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
2023-05-19 14:22:14 +02:00
|
|
|
import com.viaversion.viaversion.api.type.Type;
|
2023-10-19 01:28:12 +02:00
|
|
|
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
2023-03-22 18:49:18 +01:00
|
|
|
import com.viaversion.viaversion.api.type.types.version.Types1_20;
|
|
|
|
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
|
|
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
|
|
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4;
|
|
|
|
import com.viaversion.viaversion.protocols.protocol1_20to1_19_4.packets.EntityPackets;
|
|
|
|
import com.viaversion.viaversion.protocols.protocol1_20to1_19_4.packets.InventoryPackets;
|
|
|
|
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
|
|
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
|
|
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
|
|
|
|
|
|
|
public final class Protocol1_20To1_19_4 extends AbstractProtocol<ClientboundPackets1_19_4, ClientboundPackets1_19_4, ServerboundPackets1_19_4, ServerboundPackets1_19_4> {
|
|
|
|
|
|
|
|
public static final MappingData MAPPINGS = new MappingDataBase("1.19.4", "1.20");
|
|
|
|
private final EntityPackets entityRewriter = new EntityPackets(this);
|
|
|
|
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
2024-04-18 16:12:57 +02:00
|
|
|
private final TagRewriter<ClientboundPackets1_19_4> tagRewriter = new TagRewriter<>(this);
|
2023-03-22 18:49:18 +01:00
|
|
|
|
|
|
|
public Protocol1_20To1_19_4() {
|
|
|
|
super(ClientboundPackets1_19_4.class, ClientboundPackets1_19_4.class, ServerboundPackets1_19_4.class, ServerboundPackets1_19_4.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void registerPackets() {
|
|
|
|
super.registerPackets();
|
|
|
|
|
|
|
|
tagRewriter.registerGeneric(ClientboundPackets1_19_4.TAGS);
|
|
|
|
|
|
|
|
final SoundRewriter<ClientboundPackets1_19_4> soundRewriter = new SoundRewriter<>(this);
|
|
|
|
soundRewriter.register1_19_3Sound(ClientboundPackets1_19_4.SOUND);
|
2024-03-14 14:43:37 +01:00
|
|
|
soundRewriter.register1_19_3Sound(ClientboundPackets1_19_4.ENTITY_SOUND);
|
2023-03-22 18:49:18 +01:00
|
|
|
|
|
|
|
new StatisticsRewriter<>(this).register(ClientboundPackets1_19_4.STATISTICS);
|
2023-05-19 14:22:14 +02:00
|
|
|
|
|
|
|
registerClientbound(ClientboundPackets1_19_4.COMBAT_END, wrapper -> {
|
|
|
|
wrapper.passthrough(Type.VAR_INT); // Duration
|
|
|
|
wrapper.read(Type.INT); // Killer ID
|
|
|
|
});
|
|
|
|
registerClientbound(ClientboundPackets1_19_4.COMBAT_KILL, wrapper -> {
|
|
|
|
wrapper.passthrough(Type.VAR_INT); // Duration
|
|
|
|
wrapper.read(Type.INT); // Killer ID
|
|
|
|
});
|
2023-03-22 18:49:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onMappingDataLoaded() {
|
|
|
|
super.onMappingDataLoaded();
|
|
|
|
Types1_20.PARTICLE.filler(this)
|
|
|
|
.reader("block", ParticleType.Readers.BLOCK)
|
|
|
|
.reader("block_marker", ParticleType.Readers.BLOCK)
|
|
|
|
.reader("dust", ParticleType.Readers.DUST)
|
|
|
|
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
|
|
|
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
|
2023-11-09 06:35:07 +01:00
|
|
|
.reader("item", ParticleType.Readers.ITEM1_13_2)
|
2023-06-06 13:28:02 +02:00
|
|
|
.reader("vibration", ParticleType.Readers.VIBRATION1_19)
|
2023-03-22 18:49:18 +01:00
|
|
|
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
|
|
|
|
.reader("shriek", ParticleType.Readers.SHRIEK);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void init(final UserConnection user) {
|
2023-10-19 01:28:12 +02:00
|
|
|
addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_19_4.PLAYER));
|
2023-03-22 18:49:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public MappingData getMappingData() {
|
|
|
|
return MAPPINGS;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EntityPackets getEntityRewriter() {
|
|
|
|
return entityRewriter;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public InventoryPackets getItemRewriter() {
|
|
|
|
return itemRewriter;
|
|
|
|
}
|
2024-04-18 16:12:57 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TagRewriter<ClientboundPackets1_19_4> getTagRewriter() {
|
|
|
|
return tagRewriter;
|
|
|
|
}
|
2023-03-22 18:49:18 +01:00
|
|
|
}
|