Clean up more item type usage in ItemRewriter (#675)

This commit is contained in:
EnZaXD 2024-01-29 17:29:17 +01:00 committed by GitHub
parent 8759f059b7
commit de21548a8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 86 additions and 97 deletions

View File

@ -36,10 +36,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public class ItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
T extends BackwardsProtocol<C, ?, ?, S>> extends ItemRewriterBase<C, S, T> {
public ItemRewriter(T protocol) {
super(protocol, true);
}
public ItemRewriter(T protocol, Type<Item> itemType, Type<Item[]> itemArrayType) {
super(protocol, itemType, itemArrayType, true);
}
@ -131,7 +127,7 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
}
@Override
public void registerAdvancements(C packetType, Type<Item> type) {
public void registerAdvancements(C packetType) {
protocol.registerClientbound(packetType, new PacketHandlers() {
@Override
public void register() {
@ -156,7 +152,7 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
translatableRewriter.processText(description);
}
handleItemToClient(wrapper.passthrough(type)); // Icon
handleItemToClient(wrapper.passthrough(getItemType())); // Icon
wrapper.passthrough(Type.VAR_INT); // Frame type
int flags = wrapper.passthrough(Type.INT); // Flags
if ((flags & 1) != 0) {

View File

@ -35,10 +35,6 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
protected final String nbtTagName;
protected final boolean jsonNameFormat;
protected ItemRewriterBase(T protocol, boolean jsonNameFormat) {
this(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_ARRAY, jsonNameFormat);
}
public ItemRewriterBase(T protocol, Type<Item> itemType, Type<Item[]> itemArrayType, boolean jsonNameFormat) {
super(protocol, itemType, itemArrayType);
this.jsonNameFormat = jsonNameFormat;

View File

@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
import com.viaversion.viaversion.libs.gson.JsonElement;
@ -106,7 +107,7 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
}
protected LegacyBlockItemRewriter(T protocol) {
super(protocol, false);
super(protocol, Type.ITEM1_8, Type.ITEM1_8_SHORT_ARRAY, false);
replacementData = LEGACY_MAPPINGS.get(protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
}

View File

@ -68,18 +68,15 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
handler(itemToClientHandler(Type.ITEM1_8));
// Handle Llama
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
if (isLlama(wrapper.user())) {
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
if (!horse.isPresent())
return;
ChestedHorseStorage storage = horse.get();
int currentSlot = wrapper.get(Type.SHORT, 0);
wrapper.set(Type.SHORT, 0, ((Integer) (currentSlot = getNewSlotId(storage, currentSlot))).shortValue());
wrapper.set(Type.ITEM1_8, 0, getNewItem(storage, currentSlot, wrapper.get(Type.ITEM1_8, 0)));
}
handler(wrapper -> {
if (isLlama(wrapper.user())) {
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
if (!horse.isPresent())
return;
ChestedHorseStorage storage = horse.get();
int currentSlot = wrapper.get(Type.SHORT, 0);
wrapper.set(Type.SHORT, 0, ((Integer) (currentSlot = getNewSlotId(storage, currentSlot))).shortValue());
wrapper.set(Type.ITEM1_8, 0, getNewItem(storage, currentSlot, wrapper.get(Type.ITEM1_8, 0)));
}
});
}
@ -113,9 +110,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
}
});
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM1_8);
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT);
// Plugin message Packet -> Trading
// Plugin message -> Trading
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
@Override
public void register() {
@ -172,7 +169,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
}
});
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM1_8);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION);
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);

View File

@ -80,9 +80,9 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
}
});
registerSetSlot(ClientboundPackets1_12.SET_SLOT, Type.ITEM1_8);
registerWindowItems(ClientboundPackets1_12.WINDOW_ITEMS, Type.ITEM1_8_SHORT_ARRAY);
registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT, Type.ITEM1_8);
registerSetSlot(ClientboundPackets1_12.SET_SLOT);
registerWindowItems(ClientboundPackets1_12.WINDOW_ITEMS);
registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT);
// Plugin message Packet -> Trading
protocol.registerClientbound(ClientboundPackets1_12.PLUGIN_MESSAGE, new PacketHandlers() {
@ -148,7 +148,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
}
});
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM1_8);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION);
protocol.registerClientbound(ClientboundPackets1_12.CHUNK_DATA, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);

View File

@ -39,9 +39,9 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
@Override
protected void registerPackets() {
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM1_8);
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM1_8_SHORT_ARRAY);
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM1_8);
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT);
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS);
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT);
// Plugin message Packet -> Trading
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
@ -72,8 +72,8 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
}
});
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM1_8);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM1_8);
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION);
// Handle item metadata
protocol.getEntityRewriter().filter().handler((event, meta) -> {

View File

@ -69,7 +69,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
private final String extraNbtTag;
public BlockItemPackets1_13(Protocol1_12_2To1_13 protocol) {
super(protocol);
super(protocol, null, null);
extraNbtTag = "VB|" + protocol.getClass().getSimpleName() + "|2";
}
@ -237,7 +237,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
@Override
public void register() {
map(Type.UNSIGNED_BYTE);
map(Type.ITEM1_13_ARRAY, Type.ITEM1_8_SHORT_ARRAY);
map(Type.ITEM1_13_SHORT_ARRAY, Type.ITEM1_8_SHORT_ARRAY);
handler(itemArrayToClientHandler(Type.ITEM1_8_SHORT_ARRAY));
}

View File

@ -39,7 +39,7 @@ public class InventoryPackets1_13_2 {
@Override
public void register() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.ITEM1_13_2_SHORT_ARRAY, Type.ITEM1_13_ARRAY); // 1 - Window Values
map(Type.ITEM1_13_2_SHORT_ARRAY, Type.ITEM1_13_SHORT_ARRAY); // 1 - Window Values
}
});

View File

@ -64,7 +64,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
private EnchantmentRewriter enchantmentRewriter;
public BlockItemPackets1_14(Protocol1_13_2To1_14 protocol) {
super(protocol);
super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_SHORT_ARRAY);
}
@Override
@ -170,9 +170,9 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
BlockRewriter<ClientboundPackets1_14> blockRewriter = BlockRewriter.legacy(protocol);
registerSetCooldown(ClientboundPackets1_14.COOLDOWN);
registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY);
registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.ITEM1_13_2);
registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS, Type.ITEM1_13_2);
registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS);
registerSetSlot(ClientboundPackets1_14.SET_SLOT);
registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS);
// Trade List -> Plugin Message
protocol.registerClientbound(ClientboundPackets1_14.TRADE_LIST, ClientboundPackets1_13.PLUGIN_MESSAGE, wrapper -> {
@ -293,8 +293,8 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
});
registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW);
registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION);
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_BREAK_ANIMATION, new PacketHandlers() {
@Override
@ -436,7 +436,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
}
});
registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, Type.ITEM1_13_2, Type.FLOAT);
registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, Type.FLOAT);
protocol.registerClientbound(ClientboundPackets1_14.MAP_DATA, new PacketHandlers() {
@Override

View File

@ -27,14 +27,14 @@ import com.viaversion.viaversion.rewriter.ItemRewriter;
public class InventoryPackets1_13_1 extends ItemRewriter<ClientboundPackets1_13, ServerboundPackets1_13, Protocol1_13To1_13_1> {
public InventoryPackets1_13_1(Protocol1_13To1_13_1 protocol) {
super(protocol, Type.ITEM1_13, Type.ITEM1_13_ARRAY);
super(protocol, Type.ITEM1_13, Type.ITEM1_13_SHORT_ARRAY);
}
@Override
public void registerPackets() {
registerSetCooldown(ClientboundPackets1_13.COOLDOWN);
registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.ITEM1_13_ARRAY);
registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.ITEM1_13);
registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS);
registerSetSlot(ClientboundPackets1_13.SET_SLOT);
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, wrapper -> {
String channel = wrapper.passthrough(Type.STRING);
@ -64,10 +64,10 @@ public class InventoryPackets1_13_1 extends ItemRewriter<ClientboundPackets1_13,
}
});
registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.ITEM1_13);
registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.ITEM1_13);
registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13);
registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT);
registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW);
registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION);
registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, Type.ITEM1_13, Type.FLOAT);
registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, Type.FLOAT);
}
}

View File

@ -35,7 +35,7 @@ import com.viaversion.viaversion.rewriter.RecipeRewriter;
public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter<ClientboundPackets1_15, ServerboundPackets1_14, Protocol1_14_4To1_15> {
public BlockItemPackets1_15(Protocol1_14_4To1_15 protocol) {
super(protocol);
super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_SHORT_ARRAY);
}
@Override
@ -47,13 +47,13 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2)));
registerSetCooldown(ClientboundPackets1_15.COOLDOWN);
registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY);
registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.ITEM1_13_2);
registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS);
registerSetSlot(ClientboundPackets1_15.SET_SLOT);
registerTradeList(ClientboundPackets1_15.TRADE_LIST);
registerEntityEquipment(ClientboundPackets1_15.ENTITY_EQUIPMENT, Type.ITEM1_13_2);
registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS, Type.ITEM1_13_2);
registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerEntityEquipment(ClientboundPackets1_15.ENTITY_EQUIPMENT);
registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS);
registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW);
registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING);
blockRewriter.registerBlockAction(ClientboundPackets1_15.BLOCK_ACTION);

View File

@ -60,7 +60,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
private EnchantmentRewriter enchantmentRewriter;
public BlockItemPackets1_16(Protocol1_15_2To1_16 protocol) {
super(protocol);
super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_SHORT_ARRAY);
}
@Override
@ -94,10 +94,10 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
});
registerSetCooldown(ClientboundPackets1_16.COOLDOWN);
registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY);
registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.ITEM1_13_2);
registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS);
registerSetSlot(ClientboundPackets1_16.SET_SLOT);
registerTradeList(ClientboundPackets1_16.TRADE_LIST);
registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS, Type.ITEM1_13_2);
registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16.ACKNOWLEDGE_PLAYER_DIGGING);
blockRewriter.registerBlockAction(ClientboundPackets1_16.BLOCK_ACTION);
@ -205,7 +205,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001);
registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, Type.ITEM1_13_2, Type.DOUBLE);
registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, Type.DOUBLE);
protocol.registerClientbound(ClientboundPackets1_16.WINDOW_PROPERTY, new PacketHandlers() {
@Override
@ -245,8 +245,8 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
handleBlockEntity(tag);
});
registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW);
registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION);
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2)));
}

View File

@ -41,7 +41,7 @@ import com.viaversion.viaversion.rewriter.RecipeRewriter;
public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter<ClientboundPackets1_16_2, ServerboundPackets1_16, Protocol1_16_1To1_16_2> {
public BlockItemPackets1_16_2(Protocol1_16_1To1_16_2 protocol) {
super(protocol);
super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_SHORT_ARRAY);
}
@Override
@ -51,11 +51,11 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
new RecipeRewriter<>(protocol).register(ClientboundPackets1_16_2.DECLARE_RECIPES);
registerSetCooldown(ClientboundPackets1_16_2.COOLDOWN);
registerWindowItems(ClientboundPackets1_16_2.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY);
registerSetSlot(ClientboundPackets1_16_2.SET_SLOT, Type.ITEM1_13_2);
registerWindowItems(ClientboundPackets1_16_2.WINDOW_ITEMS);
registerSetSlot(ClientboundPackets1_16_2.SET_SLOT);
registerEntityEquipmentArray(ClientboundPackets1_16_2.ENTITY_EQUIPMENT);
registerTradeList(ClientboundPackets1_16_2.TRADE_LIST);
registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS, Type.ITEM1_13_2);
registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS);
protocol.registerClientbound(ClientboundPackets1_16_2.UNLOCK_RECIPES, wrapper -> {
wrapper.passthrough(Type.VAR_INT);
@ -132,10 +132,10 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
blockRewriter.registerEffect(ClientboundPackets1_16_2.EFFECT, 1010, 2001);
registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.ITEM1_13_2, Type.DOUBLE);
registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.DOUBLE);
registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW);
registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION);
protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2)));
}

View File

@ -56,7 +56,7 @@ import java.util.List;
public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1_17, ServerboundPackets1_16_2, Protocol1_16_4To1_17> {
public BlockItemPackets1_17(Protocol1_16_4To1_17 protocol) {
super(protocol);
super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_SHORT_ARRAY);
}
@Override
@ -66,17 +66,17 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
new RecipeRewriter<>(protocol).register(ClientboundPackets1_17.DECLARE_RECIPES);
registerSetCooldown(ClientboundPackets1_17.COOLDOWN);
registerWindowItems(ClientboundPackets1_17.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY);
registerWindowItems(ClientboundPackets1_17.WINDOW_ITEMS);
registerEntityEquipmentArray(ClientboundPackets1_17.ENTITY_EQUIPMENT);
registerTradeList(ClientboundPackets1_17.TRADE_LIST);
registerAdvancements(ClientboundPackets1_17.ADVANCEMENTS, Type.ITEM1_13_2);
registerAdvancements(ClientboundPackets1_17.ADVANCEMENTS);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_17.ACKNOWLEDGE_PLAYER_DIGGING);
blockRewriter.registerBlockAction(ClientboundPackets1_17.BLOCK_ACTION);
blockRewriter.registerEffect(ClientboundPackets1_17.EFFECT, 1010, 2001);
registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION);
protocol.registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2)));
// TODO Since the carried and modified items are typically set incorrectly, the server sends unnecessary

View File

@ -50,7 +50,7 @@ import java.util.List;
public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1_18, ServerboundPackets1_17, Protocol1_17_1To1_18> {
public BlockItemPackets1_18(final Protocol1_17_1To1_18 protocol) {
super(protocol);
super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_ARRAY);
}
@Override
@ -62,7 +62,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
registerSetSlot1_17_1(ClientboundPackets1_18.SET_SLOT);
registerEntityEquipmentArray(ClientboundPackets1_18.ENTITY_EQUIPMENT);
registerTradeList(ClientboundPackets1_18.TRADE_LIST);
registerAdvancements(ClientboundPackets1_18.ADVANCEMENTS, Type.ITEM1_13_2);
registerAdvancements(ClientboundPackets1_18.ADVANCEMENTS);
registerClickWindow1_17_1(ServerboundPackets1_17.CLICK_WINDOW);
protocol.registerClientbound(ClientboundPackets1_18.EFFECT, new PacketHandlers() {
@ -81,7 +81,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
}
});
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION);
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_PARTICLE, new PacketHandlers() {
@Override

View File

@ -39,7 +39,7 @@ import com.viaversion.viaversion.util.MathUtil;
public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1_19, ServerboundPackets1_17, Protocol1_18_2To1_19> {
public BlockItemPackets1_19(final Protocol1_18_2To1_19 protocol) {
super(protocol);
super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_ARRAY);
}
@Override
@ -52,7 +52,7 @@ public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1
registerWindowItems1_17_1(ClientboundPackets1_19.WINDOW_ITEMS);
registerSetSlot1_17_1(ClientboundPackets1_19.SET_SLOT);
registerEntityEquipmentArray(ClientboundPackets1_19.ENTITY_EQUIPMENT);
registerAdvancements(ClientboundPackets1_19.ADVANCEMENTS, Type.ITEM1_13_2);
registerAdvancements(ClientboundPackets1_19.ADVANCEMENTS);
registerClickWindow1_17_1(ServerboundPackets1_17.CLICK_WINDOW);
blockRewriter.registerBlockAction(ClientboundPackets1_19.BLOCK_ACTION);
@ -60,7 +60,7 @@ public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1
blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_19.MULTI_BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_19.EFFECT, 1010, 2001);
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION);
protocol.registerClientbound(ClientboundPackets1_19.TRADE_LIST, new PacketHandlers() {
@Override

View File

@ -32,7 +32,7 @@ import com.viaversion.viaversion.util.Key;
public final class BlockItemPackets1_19_3 extends ItemRewriter<ClientboundPackets1_19_3, ServerboundPackets1_19_1, Protocol1_19_1To1_19_3> {
public BlockItemPackets1_19_3(final Protocol1_19_1To1_19_3 protocol) {
super(protocol);
super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_ARRAY);
}
@Override
@ -49,10 +49,10 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter<ClientboundPacket
registerWindowItems1_17_1(ClientboundPackets1_19_3.WINDOW_ITEMS);
registerSetSlot1_17_1(ClientboundPackets1_19_3.SET_SLOT);
registerEntityEquipmentArray(ClientboundPackets1_19_3.ENTITY_EQUIPMENT);
registerAdvancements(ClientboundPackets1_19_3.ADVANCEMENTS, Type.ITEM1_13_2);
registerAdvancements(ClientboundPackets1_19_3.ADVANCEMENTS);
registerClickWindow1_17_1(ServerboundPackets1_19_1.CLICK_WINDOW);
registerTradeList1_19(ClientboundPackets1_19_3.TRADE_LIST);
registerCreativeInvAction(ServerboundPackets1_19_1.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_19_1.CREATIVE_INVENTORY_ACTION);
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_3.WINDOW_PROPERTY);
registerSpawnParticle1_19(ClientboundPackets1_19_3.SPAWN_PARTICLE);

View File

@ -32,7 +32,7 @@ import com.viaversion.viaversion.util.Key;
public final class BlockItemPackets1_19_4 extends ItemRewriter<ClientboundPackets1_19_4, ServerboundPackets1_19_3, Protocol1_19_3To1_19_4> {
public BlockItemPackets1_19_4(final Protocol1_19_3To1_19_4 protocol) {
super(protocol);
super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_ARRAY);
}
@Override
@ -67,11 +67,11 @@ public final class BlockItemPackets1_19_4 extends ItemRewriter<ClientboundPacket
registerSetCooldown(ClientboundPackets1_19_4.COOLDOWN);
registerWindowItems1_17_1(ClientboundPackets1_19_4.WINDOW_ITEMS);
registerSetSlot1_17_1(ClientboundPackets1_19_4.SET_SLOT);
registerAdvancements(ClientboundPackets1_19_4.ADVANCEMENTS, Type.ITEM1_13_2);
registerAdvancements(ClientboundPackets1_19_4.ADVANCEMENTS);
registerEntityEquipmentArray(ClientboundPackets1_19_4.ENTITY_EQUIPMENT);
registerClickWindow1_17_1(ServerboundPackets1_19_3.CLICK_WINDOW);
registerTradeList1_19(ClientboundPackets1_19_4.TRADE_LIST);
registerCreativeInvAction(ServerboundPackets1_19_3.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_19_3.CREATIVE_INVENTORY_ACTION);
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_4.WINDOW_PROPERTY);
registerSpawnParticle1_19(ClientboundPackets1_19_4.SPAWN_PARTICLE);

View File

@ -46,7 +46,7 @@ public final class BlockItemPackets1_20 extends ItemRewriter<ClientboundPackets1
private static final Set<String> NEW_TRIM_PATTERNS = new HashSet<>(Arrays.asList("host", "raiser", "shaper", "silence", "wayfinder"));
public BlockItemPackets1_20(final Protocol1_19_4To1_20 protocol) {
super(protocol);
super(protocol, Type.ITEM1_13_2, Type.ITEM1_13_2_ARRAY);
}
@Override
@ -91,7 +91,7 @@ public final class BlockItemPackets1_20 extends ItemRewriter<ClientboundPackets1
registerEntityEquipmentArray(ClientboundPackets1_19_4.ENTITY_EQUIPMENT);
registerClickWindow1_17_1(ServerboundPackets1_19_4.CLICK_WINDOW);
registerTradeList1_19(ClientboundPackets1_19_4.TRADE_LIST);
registerCreativeInvAction(ServerboundPackets1_19_4.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_19_4.CREATIVE_INVENTORY_ACTION);
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_4.WINDOW_PROPERTY);
registerSpawnParticle1_19(ClientboundPackets1_19_4.SPAWN_PARTICLE);

View File

@ -38,11 +38,10 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
@Override
protected void registerPackets() {
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM1_8);
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM1_8_SHORT_ARRAY);
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT);
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS);
// Entity Equipment Packet
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM1_8);
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT);
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
@Override
@ -72,8 +71,8 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
}
});
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM1_8);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM1_8);
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION);
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);