2023-10-16 14:30:12 +02: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-10-16 14:30:12 +02: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.template.protocols.rewriter;
|
|
|
|
|
2023-10-19 13:08:00 +02:00
|
|
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
2024-02-12 09:51:47 +01:00
|
|
|
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
2023-11-09 06:35:07 +01:00
|
|
|
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.rewriter.RecipeRewriter1_20_3;
|
2024-01-26 15:48:10 +01:00
|
|
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPacket1_20_5;
|
2024-01-17 21:04:44 +01:00
|
|
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundPackets1_20_5;
|
2024-01-26 15:48:10 +01:00
|
|
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPacket1_20_5;
|
2024-01-17 21:04:44 +01:00
|
|
|
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPackets1_20_5;
|
2023-10-16 14:30:12 +02:00
|
|
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
2024-02-29 19:59:18 +01:00
|
|
|
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
|
2023-10-16 14:30:12 +02:00
|
|
|
import com.viaversion.viaversion.template.protocols.Protocol1_99To_98;
|
|
|
|
|
|
|
|
// To replace if needed:
|
2023-10-18 11:48:19 +02:00
|
|
|
// ChunkType1_20_2
|
2023-12-03 10:00:27 +01:00
|
|
|
// RecipeRewriter1_20_3
|
2024-02-29 19:59:18 +01:00
|
|
|
public final class BlockItemPacketRewriter1_99 extends StructuredItemRewriter<ClientboundPacket1_20_5, ServerboundPacket1_20_5, Protocol1_99To_98> {
|
2023-10-16 14:30:12 +02:00
|
|
|
|
|
|
|
public BlockItemPacketRewriter1_99(final Protocol1_99To_98 protocol) {
|
2024-02-29 18:23:46 +01:00
|
|
|
super(protocol, /*TypesOLD.ITEM, TypesOLD.ITEM_ARRAY, */Types1_20_5.ITEM, Types1_20_5.ITEM_ARRAY);
|
2023-10-16 14:30:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerPackets() {
|
|
|
|
// Register block and block state id changes
|
|
|
|
// Other places using block state id mappings: Spawn particle, entity metadata, entity spawn (falling blocks)
|
|
|
|
// Tags and statistics use block (!) ids
|
2024-01-26 15:48:10 +01:00
|
|
|
final BlockRewriter<ClientboundPacket1_20_5> blockRewriter = BlockRewriter.for1_20_2(protocol);
|
2024-01-17 21:04:44 +01:00
|
|
|
blockRewriter.registerBlockAction(ClientboundPackets1_20_5.BLOCK_ACTION);
|
|
|
|
blockRewriter.registerBlockChange(ClientboundPackets1_20_5.BLOCK_CHANGE);
|
|
|
|
blockRewriter.registerVarLongMultiBlockChange1_20(ClientboundPackets1_20_5.MULTI_BLOCK_CHANGE);
|
|
|
|
blockRewriter.registerEffect(ClientboundPackets1_20_5.EFFECT, 1010, 2001);
|
|
|
|
blockRewriter.registerChunkData1_19(ClientboundPackets1_20_5.CHUNK_DATA, ChunkType1_20_2::new);
|
|
|
|
blockRewriter.registerBlockEntityData(ClientboundPackets1_20_5.BLOCK_ENTITY_DATA);
|
2023-10-16 14:30:12 +02:00
|
|
|
|
|
|
|
// Registers item id changes
|
|
|
|
// Other places using item ids are: Entity metadata, tags, statistics, effect
|
2024-01-17 21:04:44 +01:00
|
|
|
// registerOpenWindow(ClientboundPackets1_20_5.OPEN_WINDOW); - If a new container type was added
|
|
|
|
registerSetCooldown(ClientboundPackets1_20_5.COOLDOWN);
|
|
|
|
registerWindowItems1_17_1(ClientboundPackets1_20_5.WINDOW_ITEMS);
|
|
|
|
registerSetSlot1_17_1(ClientboundPackets1_20_5.SET_SLOT);
|
|
|
|
registerAdvancements1_20_3(ClientboundPackets1_20_5.ADVANCEMENTS);
|
|
|
|
registerEntityEquipmentArray(ClientboundPackets1_20_5.ENTITY_EQUIPMENT);
|
|
|
|
registerClickWindow1_17_1(ServerboundPackets1_20_5.CLICK_WINDOW);
|
|
|
|
registerTradeList1_20_5(ClientboundPackets1_20_5.TRADE_LIST);
|
|
|
|
registerCreativeInvAction(ServerboundPackets1_20_5.CREATIVE_INVENTORY_ACTION);
|
|
|
|
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_20_5.WINDOW_PROPERTY);
|
2024-02-12 09:51:47 +01:00
|
|
|
registerSpawnParticle1_20_5(ClientboundPackets1_20_5.SPAWN_PARTICLE, Types1_20_5.PARTICLE, Types1_20_5.PARTICLE);
|
|
|
|
registerExplosion(ClientboundPackets1_20_5.EXPLOSION, Types1_20_5.PARTICLE, Types1_20_5.PARTICLE); // Rewrites the included sound and particles
|
2023-10-16 14:30:12 +02:00
|
|
|
|
2024-02-12 09:51:47 +01:00
|
|
|
new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_20_5.DECLARE_RECIPES);
|
2023-10-16 14:30:12 +02:00
|
|
|
// OR do this if serialization of recipes changed and override the relevant method
|
|
|
|
// Add new serializers to RecipeRewriter, or extend the last one for changes
|
2024-01-17 21:04:44 +01:00
|
|
|
// new RecipeRewriter1_20_3<ClientboundPackets1_20_5>(this) {}.register1_20_5(ClientboundPackets1_20_5.DECLARE_RECIPES);
|
2023-10-16 14:30:12 +02:00
|
|
|
}
|
|
|
|
}
|