65 lines
3.6 KiB
Java
65 lines
3.6 KiB
Java
/*
|
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
|
* Copyright (C) 2023 ViaVersion and contributors
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package com.viaversion.viaversion.protocols.protocol1_20_2to1_20.handler;
|
|
|
|
import com.viaversion.viaversion.api.minecraft.metadata.ChunkPosition;
|
|
import com.viaversion.viaversion.api.type.Type;
|
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
|
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
|
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.rewriter.RecipeRewriter1_19_4;
|
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.Protocol1_20_2To1_20;
|
|
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
|
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
|
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
|
|
|
public final class BlockItemPacketHandler1_20_2 extends ItemRewriter<ClientboundPackets1_19_4, ServerboundPackets1_20_2, Protocol1_20_2To1_20> {
|
|
|
|
public BlockItemPacketHandler1_20_2(final Protocol1_20_2To1_20 protocol) {
|
|
super(protocol);
|
|
}
|
|
|
|
@Override
|
|
public void registerPackets() {
|
|
final BlockRewriter<ClientboundPackets1_19_4> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
|
|
blockRewriter.registerBlockAction(ClientboundPackets1_19_4.BLOCK_ACTION);
|
|
blockRewriter.registerBlockChange(ClientboundPackets1_19_4.BLOCK_CHANGE);
|
|
blockRewriter.registerVarLongMultiBlockChange1_20(ClientboundPackets1_19_4.MULTI_BLOCK_CHANGE);
|
|
blockRewriter.registerEffect(ClientboundPackets1_19_4.EFFECT, 1010, 2001);
|
|
blockRewriter.registerChunkData1_19(ClientboundPackets1_19_4.CHUNK_DATA, Chunk1_18Type::new);
|
|
blockRewriter.registerBlockEntityData(ClientboundPackets1_19_4.BLOCK_ENTITY_DATA);
|
|
|
|
registerSetCooldown(ClientboundPackets1_19_4.COOLDOWN);
|
|
registerWindowItems1_17_1(ClientboundPackets1_19_4.WINDOW_ITEMS);
|
|
registerSetSlot1_17_1(ClientboundPackets1_19_4.SET_SLOT);
|
|
registerAdvancements1_20(ClientboundPackets1_19_4.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
|
registerEntityEquipmentArray(ClientboundPackets1_19_4.ENTITY_EQUIPMENT);
|
|
registerClickWindow1_17_1(ServerboundPackets1_20_2.CLICK_WINDOW);
|
|
registerTradeList1_19(ClientboundPackets1_19_4.TRADE_LIST);
|
|
registerCreativeInvAction(ServerboundPackets1_20_2.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
|
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_4.WINDOW_PROPERTY);
|
|
registerSpawnParticle1_19(ClientboundPackets1_19_4.SPAWN_PARTICLE);
|
|
|
|
new RecipeRewriter1_19_4<>(protocol).register(ClientboundPackets1_19_4.DECLARE_RECIPES);
|
|
|
|
protocol.registerClientbound(ClientboundPackets1_19_4.UNLOAD_CHUNK, wrapper -> {
|
|
final int x = wrapper.read(Type.INT);
|
|
final int z = wrapper.read(Type.INT);
|
|
wrapper.write(Type.CHUNK_POSITION, new ChunkPosition(x, z));
|
|
});
|
|
}
|
|
} |