3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-11-17 13:30:14 +01:00

Update VV usage

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-10-19 21:31:00 +10:00
Ursprung 4cd65dd956
Commit 7f85d074af
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
45 geänderte Dateien mit 307 neuen und 310 gelöschten Zeilen

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.Int2IntMapMappings;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.data.entity.TrackedEntity;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
@ -35,7 +36,6 @@ 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;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.EntityRewriter;
import com.viaversion.viaversion.rewriter.meta.MetaHandlerEvent;
import java.util.List;

Datei anzeigen

@ -36,7 +36,7 @@ public abstract class ItemRewriterBase<C extends ClientboundPacketType, S extend
protected final boolean jsonNameFormat;
protected ItemRewriterBase(T protocol, boolean jsonNameFormat) {
this(protocol, Type.FLAT_VAR_INT_ITEM, Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, 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) {

Datei anzeigen

@ -22,6 +22,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.entities.storage.EntityData;
import com.viaversion.viabackwards.api.entities.storage.EntityObjectData;
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.ObjectType;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
@ -32,7 +33,6 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Datei anzeigen

@ -26,11 +26,11 @@ import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.EntityPac
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets1_11;
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {

Datei anzeigen

@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.api.minecraft.item.DataItem;
@ -36,6 +37,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
@ -43,9 +45,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_11to1_10.EntityIdRewriter;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type;
import java.util.Arrays;
import java.util.Optional;
@ -64,9 +63,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
public void register() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.SHORT); // 1 - Slot ID
map(Type.ITEM); // 2 - Slot Value
map(Type.ITEM1_8); // 2 - Slot Value
handler(itemToClientHandler(Type.ITEM));
handler(itemToClientHandler(Type.ITEM1_8));
// Handle Llama
handler(new PacketHandler() {
@ -79,7 +78,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
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.ITEM, 0, getNewItem(storage, currentSlot, wrapper.get(Type.ITEM, 0)));
wrapper.set(Type.ITEM1_8, 0, getNewItem(storage, currentSlot, wrapper.get(Type.ITEM1_8, 0)));
}
}
});
@ -114,7 +113,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
}
});
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM1_8);
// Plugin message Packet -> Trading
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
@ -128,12 +127,12 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Input Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Output Item
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
if (secondItem) {
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Second Item
}
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
@ -153,9 +152,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
map(Type.BYTE); // 2 - Button
map(Type.SHORT); // 3 - Action number
map(Type.VAR_INT); // 4 - Mode
map(Type.ITEM); // 5 - Clicked Item
map(Type.ITEM1_8); // 5 - Clicked Item
handler(itemToServerHandler(Type.ITEM));
handler(itemToServerHandler(Type.ITEM1_8));
// Llama slot
handler(wrapper -> {
@ -173,12 +172,12 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
}
});
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM1_8);
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.10 Chunk type since nothing changed.
ChunkType1_9_3 type = new ChunkType1_9_3(clientWorld); // Use the 1.10 Chunk type since nothing changed.
Chunk chunk = wrapper.passthrough(type);
handleChunk(chunk);
@ -198,7 +197,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION); // 0 - Block Position
map(Type.POSITION1_8); // 0 - Block Position
map(Type.VAR_INT); // 1 - Block
handler(wrapper -> {
@ -226,7 +225,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION); // 0 - Position
map(Type.POSITION1_8); // 0 - Position
map(Type.UNSIGNED_BYTE); // 1 - Action
map(Type.NAMED_COMPOUND_TAG); // 2 - NBT
@ -299,7 +298,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
});
protocol.getEntityRewriter().filter().handler((event, meta) -> {
if (meta.metaType().type().equals(Type.ITEM)) // Is Item
if (meta.metaType().type().equals(Type.ITEM1_8)) // Is Item
meta.setValue(handleItemToClient((Item) meta.getValue()));
});
}

Datei anzeigen

@ -50,7 +50,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
@Override
public void register() {
map(Type.INT);
map(Type.POSITION);
map(Type.POSITION1_8);
map(Type.INT);
handler(wrapper -> {
int type = wrapper.get(Type.INT, 0);

Datei anzeigen

@ -81,7 +81,7 @@ public class PlayerPackets1_11 {
protocol.registerServerbound(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION); // 0 - Location
map(Type.POSITION1_8); // 0 - Location
map(Type.VAR_INT); // 1 - Face
map(Type.VAR_INT); // 2 - Hand

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.ChatPac
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.EntityPackets1_12;
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.SoundPackets1_12;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
@ -34,7 +35,6 @@ import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPacke
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_12, ClientboundPackets1_9_3, ServerboundPackets1_12, ServerboundPackets1_9_3> {

Datei anzeigen

@ -22,11 +22,13 @@ import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.MapColorMapping;
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag;
@ -34,11 +36,8 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.Iterator;
import java.util.Map;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type;
import org.checkerframework.checker.nullness.qual.Nullable;
public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPackets1_12, ServerboundPackets1_9_3, Protocol1_11_1To1_12> {
@ -81,9 +80,9 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
}
});
registerSetSlot(ClientboundPackets1_12.SET_SLOT, Type.ITEM);
registerSetSlot(ClientboundPackets1_12.SET_SLOT, Type.ITEM1_8);
registerWindowItems(ClientboundPackets1_12.WINDOW_ITEMS, Type.ITEM1_8_ARRAY);
registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT, Type.ITEM);
registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT, Type.ITEM1_8);
// Plugin message Packet -> Trading
protocol.registerClientbound(ClientboundPackets1_12.PLUGIN_MESSAGE, new PacketHandlers() {
@ -97,12 +96,12 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Input Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Output Item
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
if (secondItem)
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Second Item
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
wrapper.passthrough(Type.INT); // Number of tools uses
@ -121,7 +120,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
map(Type.BYTE); // 2 - Button
map(Type.SHORT); // 3 - Action number
map(Type.VAR_INT); // 4 - Mode
map(Type.ITEM); // 5 - Clicked Item
map(Type.ITEM1_8); // 5 - Clicked Item
handler(wrapper -> {
if (wrapper.get(Type.VAR_INT, 0) == 1) { // Shift click
@ -129,7 +128,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
// Previously clients grab the item from the clicked slot *before* it has
// been moved however now they grab the slot item *after* it has been moved
// and send that in the packet.
wrapper.set(Type.ITEM, 0, null); // Set null item (probably will work)
wrapper.set(Type.ITEM1_8, 0, null); // Set null item (probably will work)
// Apologize (may happen in some cases, maybe if inventory is full?)
PacketWrapper confirm = wrapper.create(ServerboundPackets1_12.WINDOW_CONFIRMATION);
@ -143,18 +142,18 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
return;
}
Item item = wrapper.get(Type.ITEM, 0);
Item item = wrapper.get(Type.ITEM1_8, 0);
handleItemToServer(item);
});
}
});
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM1_8);
protocol.registerClientbound(ClientboundPackets1_12.CHUNK_DATA, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.9.4 Chunk type since nothing changed.
ChunkType1_9_3 type = new ChunkType1_9_3(clientWorld); // Use the 1.9.4 Chunk type since nothing changed.
Chunk chunk = wrapper.passthrough(type);
handleChunk(chunk);
@ -163,7 +162,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_CHANGE, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION); // 0 - Block Position
map(Type.POSITION1_8); // 0 - Block Position
map(Type.VAR_INT); // 1 - Block
handler(wrapper -> {
@ -191,7 +190,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_ENTITY_DATA, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION); // 0 - Position
map(Type.POSITION1_8); // 0 - Position
map(Type.UNSIGNED_BYTE); // 1 - Action
map(Type.NAMED_COMPOUND_TAG); // 2 - NBT
@ -204,7 +203,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
});
protocol.getEntityRewriter().filter().handler((event, meta) -> {
if (meta.metaType().type().equals(Type.ITEM)) // Is Item
if (meta.metaType().type().equals(Type.ITEM1_8)) // Is Item
meta.setValue(handleItemToClient((Item) meta.getValue()));
});

Datei anzeigen

@ -22,11 +22,11 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets1_11_1;
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.ItemPackets1_11_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_11To1_11_1 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {

Datei anzeigen

@ -39,9 +39,9 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
@Override
protected void registerPackets() {
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM);
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM1_8);
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM1_8_ARRAY);
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM1_8);
// Plugin message Packet -> Trading
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
@ -55,12 +55,12 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Input Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Output Item
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
if (secondItem) {
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Second Item
}
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
@ -72,12 +72,12 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
}
});
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM1_8);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM1_8);
// Handle item metadata
protocol.getEntityRewriter().filter().handler((event, meta) -> {
if (meta.metaType().type().equals(Type.ITEM)) { // Is Item
if (meta.metaType().type().equals(Type.ITEM1_8)) { // Is Item
meta.setValue(handleItemToClient((Item) meta.getValue()));
}
});

Datei anzeigen

@ -33,6 +33,7 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerP
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.libs.gson.JsonElement;
@ -46,7 +47,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import org.checkerframework.checker.nullness.qual.Nullable;

Datei anzeigen

@ -28,6 +28,7 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.Backwar
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
@ -37,6 +38,8 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.viaversion.libs.opennbt.conversion.ConverterRegistry;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
@ -53,9 +56,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPacke
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.BlockIdData;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type;
import com.viaversion.viaversion.util.Key;
import java.util.ArrayList;
import java.util.HashMap;
@ -109,7 +109,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ACTION, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION); // Location
map(Type.POSITION1_8); // Location
map(Type.UNSIGNED_BYTE); // Action Id
map(Type.UNSIGNED_BYTE); // Action param
map(Type.VAR_INT); // Block Id - /!\ NOT BLOCK STATE ID
@ -145,7 +145,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION); // 0 - Position
map(Type.POSITION1_8); // 0 - Position
map(Type.UNSIGNED_BYTE); // 1 - Action
map(Type.NAMED_COMPOUND_TAG); // 2 - NBT Data
@ -160,7 +160,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
wrapper.set(Type.NAMED_COMPOUND_TAG, 0,
provider.transform(
wrapper.user(),
wrapper.get(Type.POSITION, 0),
wrapper.get(Type.POSITION1_8, 0),
wrapper.get(Type.NAMED_COMPOUND_TAG, 0)
));
});
@ -184,11 +184,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_CHANGE, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION); // 0 - Position
map(Type.POSITION1_8); // 0 - Position
handler(wrapper -> {
int blockState = wrapper.read(Type.VAR_INT);
Position position = wrapper.get(Type.POSITION, 0);
Position position = wrapper.get(Type.POSITION1_8, 0);
// Store blocks
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
@ -249,17 +249,17 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
public void register() {
map(Type.UNSIGNED_BYTE);
map(Type.SHORT);
map(Type.ITEM1_13, Type.ITEM);
map(Type.ITEM1_13, Type.ITEM1_8);
handler(itemToClientHandler(Type.ITEM));
handler(itemToClientHandler(Type.ITEM1_8));
}
});
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk1_9_3_4Type type_old = new Chunk1_9_3_4Type(clientWorld);
Chunk1_13Type type = new Chunk1_13Type(clientWorld);
ChunkType1_9_3 type_old = new ChunkType1_9_3(clientWorld);
ChunkType1_13 type = new ChunkType1_13(clientWorld);
Chunk chunk = wrapper.read(type);
// Handle Block Entities before block rewrite
@ -371,7 +371,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
@Override
public void register() {
map(Type.INT); // Effect Id
map(Type.POSITION); // Location
map(Type.POSITION1_8); // Location
map(Type.INT); // Data
handler(wrapper -> {
int id = wrapper.get(Type.INT, 0);
@ -421,9 +421,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
public void register() {
map(Type.VAR_INT);
map(Type.VAR_INT);
map(Type.ITEM1_13, Type.ITEM);
map(Type.ITEM1_13, Type.ITEM1_8);
handler(itemToClientHandler(Type.ITEM));
handler(itemToClientHandler(Type.ITEM1_8));
}
});
@ -449,7 +449,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
@Override
public void register() {
map(Type.SHORT);
map(Type.ITEM, Type.ITEM1_13);
map(Type.ITEM1_8, Type.ITEM1_13);
handler(itemToServerHandler(Type.ITEM1_13));
}
@ -463,7 +463,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
map(Type.BYTE);
map(Type.SHORT);
map(Type.VAR_INT);
map(Type.ITEM, Type.ITEM1_13);
map(Type.ITEM1_8, Type.ITEM1_13);
handler(itemToServerHandler(Type.ITEM1_13));
}
@ -966,19 +966,19 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
// Remove the flowerpot
PacketWrapper blockUpdateRemove = PacketWrapper.create(ClientboundPackets1_12_1.BLOCK_CHANGE, user);
blockUpdateRemove.write(Type.POSITION, position);
blockUpdateRemove.write(Type.POSITION1_8, position);
blockUpdateRemove.write(Type.VAR_INT, 0);
blockUpdateRemove.scheduleSend(Protocol1_12_2To1_13.class);
// Create the flowerpot
PacketWrapper blockCreate = PacketWrapper.create(ClientboundPackets1_12_1.BLOCK_CHANGE, user);
blockCreate.write(Type.POSITION, position);
blockCreate.write(Type.POSITION1_8, position);
blockCreate.write(Type.VAR_INT, Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(blockState));
blockCreate.scheduleSend(Protocol1_12_2To1_13.class);
// Send a block entity update
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_12_1.BLOCK_ENTITY_DATA, user);
wrapper.write(Type.POSITION, position);
wrapper.write(Type.POSITION1_8, position);
wrapper.write(Type.UNSIGNED_BYTE, (short) 5);
wrapper.write(Type.NAMED_COMPOUND_TAG, nbt);
wrapper.scheduleSend(Protocol1_12_2To1_13.class);

Datei anzeigen

@ -82,16 +82,16 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
for (int i = 0; i < size; i++) {
//Input Item
Item input = wrapper.read(Type.ITEM1_13);
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(input));
wrapper.write(Type.ITEM1_8, protocol.getItemRewriter().handleItemToClient(input));
//Output Item
Item output = wrapper.read(Type.ITEM1_13);
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(output));
wrapper.write(Type.ITEM1_8, protocol.getItemRewriter().handleItemToClient(output));
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
if (secondItem) {
//Second Item
Item second = wrapper.read(Type.ITEM1_13);
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(second));
wrapper.write(Type.ITEM1_8, protocol.getItemRewriter().handleItemToClient(second));
}
wrapper.passthrough(Type.BOOLEAN); //Trade disabled
@ -332,7 +332,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
String command = wrapper.read(Type.STRING);
boolean assumeCommand = wrapper.read(Type.BOOLEAN);
wrapper.read(Type.OPTIONAL_POSITION);
wrapper.read(Type.OPTIONAL_POSITION1_8);
if (!assumeCommand && !command.startsWith("/")) {
// Complete usernames for non-commands
@ -382,7 +382,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
case "MC|BSign":
case "MC|BEdit":
wrapper.setPacketType(ServerboundPackets1_13.EDIT_BOOK);
Item book = wrapper.read(Type.ITEM);
Item book = wrapper.read(Type.ITEM1_8);
wrapper.write(Type.ITEM1_13, protocol.getItemRewriter().handleItemToServer(book));
boolean signing = channel.equals("MC|BSign");
wrapper.write(Type.BOOLEAN, signing);
@ -416,7 +416,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
int y = wrapper.read(Type.INT);
int z = wrapper.read(Type.INT);
wrapper.write(Type.POSITION, new Position(x, (short) y, z));
wrapper.write(Type.POSITION1_8, new Position(x, (short) y, z));
wrapper.passthrough(Type.STRING); //Command
@ -439,7 +439,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
int x = wrapper.read(Type.INT);
int y = wrapper.read(Type.INT);
int z = wrapper.read(Type.INT);
wrapper.write(Type.POSITION, new Position(x, (short) y, z));
wrapper.write(Type.POSITION1_8, new Position(x, (short) y, z));
wrapper.write(Type.VAR_INT, wrapper.read(Type.BYTE) - 1);
String mode = wrapper.read(Type.STRING);
int modeId = mode.equals("SAVE") ? 0 : mode.equals("LOAD") ? 1 : mode.equals("CORNER") ? 2 : 3;

Datei anzeigen

@ -42,7 +42,7 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() {
@Override
public void register() {
map(Type.ITEM1_13, Type.FLAT_VAR_INT_ITEM);
map(Type.ITEM1_13, Type.ITEM1_13_2);
}
});
@ -61,7 +61,7 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.COMPONENT); // Title
wrapper.passthrough(Type.COMPONENT); // Description
Item icon = wrapper.read(Type.FLAT_VAR_INT_ITEM);
Item icon = wrapper.read(Type.ITEM1_13_2);
wrapper.write(Type.ITEM1_13, icon);
wrapper.passthrough(Type.VAR_INT); // Frame type
int flags = wrapper.passthrough(Type.INT); // Flags

Datei anzeigen

@ -31,7 +31,7 @@ public class InventoryPackets1_13_2 {
public void register() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.SHORT); // 1 - Slot ID
map(Type.FLAT_VAR_INT_ITEM, Type.ITEM1_13); // 2 - Slot Value
map(Type.ITEM1_13_2, Type.ITEM1_13); // 2 - Slot Value
}
});
@ -39,7 +39,7 @@ public class InventoryPackets1_13_2 {
@Override
public void register() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.FLAT_VAR_INT_ITEM_ARRAY, Type.ITEM1_13_ARRAY); // 1 - Window Values
map(Type.ITEM1_13_2_SHORT_ARRAY, Type.ITEM1_13_ARRAY); // 1 - Window Values
}
});
@ -55,13 +55,13 @@ public class InventoryPackets1_13_2 {
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
// Input Item
wrapper.write(Type.ITEM1_13, wrapper.read(Type.FLAT_VAR_INT_ITEM));
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
// Output Item
wrapper.write(Type.ITEM1_13, wrapper.read(Type.FLAT_VAR_INT_ITEM));
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
if (secondItem) {
wrapper.write(Type.ITEM1_13, wrapper.read(Type.FLAT_VAR_INT_ITEM));
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
}
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
@ -78,7 +78,7 @@ public class InventoryPackets1_13_2 {
public void register() {
map(Type.VAR_INT); // 0 - Entity ID
map(Type.VAR_INT); // 1 - Slot ID
map(Type.FLAT_VAR_INT_ITEM, Type.ITEM1_13); // 2 - Item
map(Type.ITEM1_13_2, Type.ITEM1_13); // 2 - Item
}
});
@ -91,22 +91,22 @@ public class InventoryPackets1_13_2 {
wrapper.passthrough(Type.STRING); // Group
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
for (int i1 = 0; i1 < ingredientsNo; i1++) {
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT));
wrapper.write(Type.ITEM1_13_ARRAY, wrapper.read(Type.ITEM1_13_2_ARRAY));
}
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
} else if (type.equals("crafting_shaped")) {
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.STRING); // Group
for (int i1 = 0; i1 < ingredientsNo; i1++) {
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT));
wrapper.write(Type.ITEM1_13_ARRAY, wrapper.read(Type.ITEM1_13_2_ARRAY));
}
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
} else if (type.equals("smelting")) {
wrapper.passthrough(Type.STRING); // Group
// Ingredient start
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT));
wrapper.write(Type.ITEM1_13_ARRAY, wrapper.read(Type.ITEM1_13_2_ARRAY));
// Ingredient end
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
wrapper.passthrough(Type.FLOAT); // EXP
wrapper.passthrough(Type.VAR_INT); // Cooking time
}
@ -121,7 +121,7 @@ public class InventoryPackets1_13_2 {
map(Type.BYTE); // 2 - Button
map(Type.SHORT); // 3 - Action number
map(Type.VAR_INT); // 4 - Mode
map(Type.ITEM1_13, Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item
map(Type.ITEM1_13, Type.ITEM1_13_2); // 5 - Clicked Item
}
});
@ -129,7 +129,7 @@ public class InventoryPackets1_13_2 {
@Override
public void register() {
map(Type.SHORT); // 0 - Slot
map(Type.ITEM1_13, Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item
map(Type.ITEM1_13, Type.ITEM1_13_2); // 1 - Clicked Item
}
});
}

Datei anzeigen

@ -42,7 +42,7 @@ public class WorldPackets1_13_2 {
handler(wrapper -> {
int id = wrapper.get(Type.INT, 0);
if (id == 27) {
wrapper.write(Type.ITEM1_13, wrapper.read(Type.FLAT_VAR_INT_ITEM));
wrapper.write(Type.ITEM1_13, wrapper.read(Type.ITEM1_13_2));
}
});
}

Datei anzeigen

@ -28,6 +28,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets.SoundPa
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
@ -36,7 +37,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPacke
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;

Datei anzeigen

@ -23,6 +23,7 @@ import com.viaversion.viabackwards.api.rewriters.EnchantmentRewriter;
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Environment;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
@ -30,12 +31,14 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionLight;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionLightImpl;
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_14;
import com.viaversion.viaversion.api.type.types.version.Types1_13;
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
import com.viaversion.viaversion.libs.gson.JsonElement;
@ -47,11 +50,8 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.rewriter.RecipeRewriter;
import java.util.ArrayList;
@ -68,7 +68,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
@Override
protected void registerPackets() {
protocol.registerServerbound(ServerboundPackets1_13.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
protocol.registerServerbound(ServerboundPackets1_13.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2)));
protocol.registerClientbound(ClientboundPackets1_14.OPEN_WINDOW, wrapper -> {
int windowId = wrapper.read(Type.VAR_INT);
@ -166,12 +166,12 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
wrapper.passthrough(Type.INT); // Entity id
});
BlockRewriter<ClientboundPackets1_14> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION);
BlockRewriter<ClientboundPackets1_14> blockRewriter = BlockRewriter.legacy(protocol);
registerSetCooldown(ClientboundPackets1_14.COOLDOWN);
registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
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);
// Trade List -> Plugin Message
protocol.registerClientbound(ClientboundPackets1_14.TRADE_LIST, ClientboundPackets1_13.PLUGIN_MESSAGE, wrapper -> {
@ -183,22 +183,22 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
// Input Item
Item input = wrapper.read(Type.FLAT_VAR_INT_ITEM);
Item input = wrapper.read(Type.ITEM1_13_2);
input = handleItemToClient(input);
wrapper.write(Type.FLAT_VAR_INT_ITEM, input);
wrapper.write(Type.ITEM1_13_2, input);
// Output Item
Item output = wrapper.read(Type.FLAT_VAR_INT_ITEM);
Item output = wrapper.read(Type.ITEM1_13_2);
output = handleItemToClient(output);
wrapper.write(Type.FLAT_VAR_INT_ITEM, output);
wrapper.write(Type.ITEM1_13_2, output);
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
if (secondItem) {
// Second Item
Item second = wrapper.read(Type.FLAT_VAR_INT_ITEM);
Item second = wrapper.read(Type.ITEM1_13_2);
second = handleItemToClient(second);
wrapper.write(Type.FLAT_VAR_INT_ITEM, second);
wrapper.write(Type.ITEM1_13_2, second);
}
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
@ -225,9 +225,9 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
public void register() {
map(Type.VAR_INT); // 0 - Entity ID
map(Type.VAR_INT); // 1 - Slot ID
map(Type.FLAT_VAR_INT_ITEM); // 2 - Item
map(Type.ITEM1_13_2); // 2 - Item
handler(itemToClientHandler(Type.FLAT_VAR_INT_ITEM));
handler(itemToClientHandler(Type.ITEM1_13_2));
handler(wrapper -> {
int entityId = wrapper.get(Type.VAR_INT, 0);
@ -239,7 +239,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
wrapper.resetReader();
wrapper.passthrough(Type.VAR_INT);
wrapper.read(Type.VAR_INT);
Item item = wrapper.read(Type.FLAT_VAR_INT_ITEM);
Item item = wrapper.read(Type.ITEM1_13_2);
int armorType = item == null || item.identifier() == 0 ? 0 : item.identifier() - 726;
if (armorType < 0 || armorType > 3) {
wrapper.cancel();
@ -268,15 +268,15 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
case "smoking":
case "campfire_cooking":
wrapper.read(Type.STRING); // Group
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
wrapper.read(Type.FLAT_VAR_INT_ITEM);
wrapper.read(Type.ITEM1_13_2_ARRAY); // Ingredients
wrapper.read(Type.ITEM1_13_2);
wrapper.read(Type.FLOAT); // EXP
wrapper.read(Type.VAR_INT); // Cooking time
break;
case "stonecutting":
wrapper.read(Type.STRING); // Group?
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
wrapper.read(Type.FLAT_VAR_INT_ITEM); // Result
wrapper.read(Type.ITEM1_13_2_ARRAY); // Ingredients
wrapper.read(Type.ITEM1_13_2); // Result
break;
}
deleted++;
@ -292,14 +292,14 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
});
registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_BREAK_ANIMATION, new PacketHandlers() {
@Override
public void register() {
map(Type.VAR_INT);
map(Type.POSITION1_14, Type.POSITION);
map(Type.POSITION1_14, Type.POSITION1_8);
map(Type.BYTE);
}
});
@ -307,14 +307,14 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_ENTITY_DATA, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION1_14, Type.POSITION);
map(Type.POSITION1_14, Type.POSITION1_8);
}
});
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_ACTION, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION1_14, Type.POSITION); // Location
map(Type.POSITION1_14, Type.POSITION1_8); // Location
map(Type.UNSIGNED_BYTE); // Action id
map(Type.UNSIGNED_BYTE); // Action param
map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE
@ -332,7 +332,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_CHANGE, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION1_14, Type.POSITION);
map(Type.POSITION1_14, Type.POSITION1_8);
map(Type.VAR_INT);
handler(wrapper -> {
int id = wrapper.get(Type.VAR_INT, 0);
@ -366,8 +366,8 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
protocol.registerClientbound(ClientboundPackets1_14.CHUNK_DATA, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk chunk = wrapper.read(new Chunk1_14Type());
wrapper.write(new Chunk1_13Type(clientWorld), chunk);
Chunk chunk = wrapper.read(new ChunkType1_14());
wrapper.write(new ChunkType1_13(clientWorld), chunk);
ChunkLightStorage.ChunkLight chunkLight = wrapper.user().get(ChunkLightStorage.class).getStoredLight(chunk.getX(), chunk.getZ());
for (int i = 0; i < chunk.getSections().length; i++) {
@ -421,7 +421,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
@Override
public void register() {
map(Type.INT); // Effect Id
map(Type.POSITION1_14, Type.POSITION); // Location
map(Type.POSITION1_14, Type.POSITION1_8); // Location
map(Type.INT); // Data
handler(wrapper -> {
int id = wrapper.get(Type.INT, 0);
@ -435,7 +435,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
}
});
registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.FLOAT);
registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, Type.ITEM1_13_2, Type.FLOAT);
protocol.registerClientbound(ClientboundPackets1_14.MAP_DATA, new PacketHandlers() {
@Override
@ -450,7 +450,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_POSITION, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION1_14, Type.POSITION);
map(Type.POSITION1_14, Type.POSITION1_8);
}
});
}

Datei anzeigen

@ -26,11 +26,12 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLi
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage;
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositionStorage1_14;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.VillagerData;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -40,7 +41,6 @@ import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.meta.MetaHandler;
public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_14, Protocol1_13_2To1_14> {
@ -58,7 +58,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
// Cache the position for every newly tracked entity
if (type == EntityTypes1_14.PAINTING) {
final Position position = wrapper.get(Type.POSITION, 0);
final Position position = wrapper.get(Type.POSITION1_8, 0);
positionHandler.cacheEntityPosition(wrapper, position.x(), position.y(), position.z(), true, false);
} else if (wrapper.getId() != ClientboundPackets1_14.JOIN_GAME.getId()) { // ignore join game
positionHandler.cacheEntityPosition(wrapper, true, false);
@ -84,7 +84,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
PacketWrapper equipmentPacket = wrapper.create(ClientboundPackets1_13.ENTITY_EQUIPMENT);
equipmentPacket.write(Type.VAR_INT, entityId);
equipmentPacket.write(Type.VAR_INT, i);
equipmentPacket.write(Type.FLAT_VAR_INT_ITEM, null);
equipmentPacket.write(Type.ITEM1_13_2, null);
equipmentPacket.send(Protocol1_13_2To1_14.class);
}
});
@ -256,7 +256,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.VAR_INT);
map(Type.UUID);
map(Type.VAR_INT);
map(Type.POSITION1_14, Type.POSITION);
map(Type.POSITION1_14, Type.POSITION1_8);
map(Type.BYTE);
// Track entity
@ -434,7 +434,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
// Use bed
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_13.USE_BED, null, event.user());
wrapper.write(Type.VAR_INT, event.entityId());
wrapper.write(Type.POSITION, position);
wrapper.write(Type.POSITION1_8, position);
try {
wrapper.scheduleSend(Protocol1_13_2To1_14.class);

Datei anzeigen

@ -49,21 +49,21 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
protocol.registerClientbound(ClientboundPackets1_14.OPEN_SIGN_EDITOR, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION1_14, Type.POSITION);
map(Type.POSITION1_14, Type.POSITION1_8);
}
});
protocol.registerServerbound(ServerboundPackets1_13.QUERY_BLOCK_NBT, new PacketHandlers() {
@Override
public void register() {
map(Type.VAR_INT);
map(Type.POSITION, Type.POSITION1_14);
map(Type.POSITION1_8, Type.POSITION1_14);
}
});
protocol.registerServerbound(ServerboundPackets1_13.PLAYER_DIGGING, new PacketHandlers() {
@Override
public void register() {
map(Type.VAR_INT); // Action
map(Type.POSITION, Type.POSITION1_14); // Position
map(Type.POSITION1_8, Type.POSITION1_14); // Position
}
});
@ -94,24 +94,24 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION, Type.POSITION1_14);
map(Type.POSITION1_8, Type.POSITION1_14);
}
});
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION, Type.POSITION1_14);
map(Type.POSITION1_8, Type.POSITION1_14);
}
});
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_SIGN, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION, Type.POSITION1_14);
map(Type.POSITION1_8, Type.POSITION1_14);
}
});
protocol.registerServerbound(ServerboundPackets1_13.PLAYER_BLOCK_PLACEMENT, wrapper -> {
Position position = wrapper.read(Type.POSITION);
Position position = wrapper.read(Type.POSITION1_8);
int face = wrapper.read(Type.VAR_INT);
int hand = wrapper.read(Type.VAR_INT);
float x = wrapper.read(Type.FLOAT);

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityP
import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets1_13_1;
import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets1_13_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.api.minecraft.item.Item;
@ -40,7 +41,6 @@ import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;

Datei anzeigen

@ -19,6 +19,7 @@ package com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets;
import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
import com.viaversion.viaversion.api.minecraft.BlockFace;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
@ -26,19 +27,18 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.BlockRewriter;
public class WorldPackets1_13_1 {
public static void register(Protocol1_13To1_13_1 protocol) {
BlockRewriter<ClientboundPackets1_13> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION);
BlockRewriter<ClientboundPackets1_13> blockRewriter = BlockRewriter.legacy(protocol);
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk chunk = wrapper.passthrough(new Chunk1_13Type(clientWorld));
Chunk chunk = wrapper.passthrough(new ChunkType1_13(clientWorld));
for (ChunkSection section : chunk.getSections()) {
if (section == null) {
@ -60,7 +60,7 @@ public class WorldPackets1_13_1 {
@Override
public void register() {
map(Type.INT); // Effect Id
map(Type.POSITION); // Location
map(Type.POSITION1_8); // Location
map(Type.INT); // Data
handler(wrapper -> {
int id = wrapper.get(Type.INT, 0);
@ -73,9 +73,9 @@ public class WorldPackets1_13_1 {
switch (data) {
case 0: // Down
case 1: // Up
Position pos = wrapper.get(Type.POSITION, 0);
Position pos = wrapper.get(Type.POSITION1_8, 0);
BlockFace relative = data == 0 ? BlockFace.BOTTOM : BlockFace.TOP;
wrapper.set(Type.POSITION, 0, pos.getRelative(relative)); // Y Offset
wrapper.set(Type.POSITION1_8, 0, pos.getRelative(relative)); // Y Offset
wrapper.set(Type.INT, 1, 4); // Self
break;
case 2: // North

Datei anzeigen

@ -35,10 +35,10 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol<ClientboundPackets
wrapper.passthrough(Type.VAR_INT);
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
wrapper.passthrough(Type.ITEM1_13_2);
wrapper.passthrough(Type.ITEM1_13_2);
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
wrapper.passthrough(Type.ITEM1_13_2);
}
wrapper.passthrough(Type.BOOLEAN);
wrapper.passthrough(Type.INT);

Datei anzeigen

@ -52,10 +52,10 @@ public class Protocol1_14_3To1_14_4 extends BackwardsProtocol<ClientboundPackets
wrapper.passthrough(Type.VAR_INT);
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
wrapper.passthrough(Type.ITEM1_13_2);
wrapper.passthrough(Type.ITEM1_13_2);
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
wrapper.passthrough(Type.ITEM1_13_2);
}
wrapper.passthrough(Type.BOOLEAN);
wrapper.passthrough(Type.INT);

Datei anzeigen

@ -25,10 +25,10 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_14;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_15;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.rewriter.RecipeRewriter;
@ -40,20 +40,20 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit
@Override
protected void registerPackets() {
BlockRewriter<ClientboundPackets1_15> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
BlockRewriter<ClientboundPackets1_15> blockRewriter = BlockRewriter.for1_14(protocol);
new RecipeRewriter<>(protocol).register(ClientboundPackets1_15.DECLARE_RECIPES);
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2)));
registerSetCooldown(ClientboundPackets1_15.COOLDOWN);
registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY);
registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.ITEM1_13_2);
registerTradeList(ClientboundPackets1_15.TRADE_LIST);
registerEntityEquipment(ClientboundPackets1_15.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
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);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING);
blockRewriter.registerBlockAction(ClientboundPackets1_15.BLOCK_ACTION);
@ -61,8 +61,8 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit
blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE);
protocol.registerClientbound(ClientboundPackets1_15.CHUNK_DATA, wrapper -> {
Chunk chunk = wrapper.read(new Chunk1_15Type());
wrapper.write(new Chunk1_14Type(), chunk);
Chunk chunk = wrapper.read(new ChunkType1_15());
wrapper.write(new ChunkType1_14(), chunk);
if (chunk.isFullChunk()) {
int[] biomeData = chunk.getBiomeData();
@ -122,8 +122,8 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit
int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
} else if (id == 32) {
Item item = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));
wrapper.write(Type.FLAT_VAR_INT_ITEM, item);
Item item = handleItemToClient(wrapper.read(Type.ITEM1_13_2));
wrapper.write(Type.ITEM1_13_2, item);
}
int mappedId = protocol.getMappingData().getNewParticleId(id);

Datei anzeigen

@ -27,6 +27,7 @@ import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.packets.BlockIt
import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.packets.EntityPackets1_16;
import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage.PlayerSneakStorage;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
import com.viaversion.viaversion.api.protocol.packet.State;
@ -39,8 +40,6 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPacke
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
import com.viaversion.viaversion.util.GsonUtil;

Datei anzeigen

@ -33,6 +33,8 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.UUIDIntArrayType;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_15;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
@ -42,10 +44,8 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.InventoryPackets;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.rewriter.RecipeRewriter;
import com.viaversion.viaversion.util.CompactArrayUtil;
@ -65,7 +65,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
@Override
protected void registerPackets() {
BlockRewriter<ClientboundPackets1_16> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
BlockRewriter<ClientboundPackets1_16> blockRewriter = BlockRewriter.for1_14(protocol);
RecipeRewriter<ClientboundPackets1_16> recipeRewriter = new RecipeRewriter<>(protocol);
// Remove new smithing type, only in this handler
@ -79,9 +79,9 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
newSize--;
wrapper.read(Type.STRING);
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
wrapper.read(Type.FLAT_VAR_INT_ITEM);
wrapper.read(Type.ITEM1_13_2_ARRAY);
wrapper.read(Type.ITEM1_13_2_ARRAY);
wrapper.read(Type.ITEM1_13_2);
continue;
}
@ -94,10 +94,10 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
});
registerSetCooldown(ClientboundPackets1_16.COOLDOWN);
registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY);
registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.ITEM1_13_2);
registerTradeList(ClientboundPackets1_16.TRADE_LIST);
registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS, Type.ITEM1_13_2);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16.ACKNOWLEDGE_PLAYER_DIGGING);
blockRewriter.registerBlockAction(ClientboundPackets1_16.BLOCK_ACTION);
@ -111,7 +111,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
byte slot;
do {
slot = wrapper.read(Type.BYTE);
Item item = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));
Item item = handleItemToClient(wrapper.read(Type.ITEM1_13_2));
int rawSlot = slot & 0x7F;
equipmentData.add(new EquipmentData(rawSlot, item));
} while ((slot & 0xFFFFFF80) != 0);
@ -119,7 +119,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
// Send first data in the current packet
EquipmentData firstData = equipmentData.get(0);
wrapper.write(Type.VAR_INT, firstData.slot);
wrapper.write(Type.FLAT_VAR_INT_ITEM, firstData.item);
wrapper.write(Type.ITEM1_13_2, firstData.item);
// If there are more items, send new packets for them
for (int i = 1; i < equipmentData.size(); i++) {
@ -127,7 +127,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
EquipmentData data = equipmentData.get(i);
equipmentPacket.write(Type.VAR_INT, entityId);
equipmentPacket.write(Type.VAR_INT, data.slot);
equipmentPacket.write(Type.FLAT_VAR_INT_ITEM, data.item);
equipmentPacket.write(Type.ITEM1_13_2, data.item);
equipmentPacket.send(Protocol1_15_2To1_16.class);
}
});
@ -142,8 +142,8 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
});
protocol.registerClientbound(ClientboundPackets1_16.CHUNK_DATA, wrapper -> {
Chunk chunk = wrapper.read(new Chunk1_16Type());
wrapper.write(new Chunk1_15Type(), chunk);
Chunk chunk = wrapper.read(new ChunkType1_16());
wrapper.write(new ChunkType1_15(), chunk);
for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection section = chunk.getSections()[i];
@ -201,7 +201,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001);
registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, Type.ITEM1_13_2, Type.DOUBLE);
protocol.registerClientbound(ClientboundPackets1_16.WINDOW_PROPERTY, new PacketHandlers() {
@Override
@ -241,10 +241,10 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
handleBlockEntity(tag);
});
registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2)));
}
private void handleBlockEntity(CompoundTag tag) {

Datei anzeigen

@ -23,9 +23,10 @@ import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.data.WorldNameT
import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage.WolfDataMaskStorage;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
@ -40,7 +41,6 @@ import com.viaversion.viaversion.api.type.types.version.Types1_16;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.util.Key;
public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Protocol1_15_2To1_16> {

Datei anzeigen

@ -26,15 +26,15 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.rewriter.RecipeRewriter;
@ -46,16 +46,16 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
@Override
protected void registerPackets() {
BlockRewriter<ClientboundPackets1_16_2> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
BlockRewriter<ClientboundPackets1_16_2> blockRewriter = BlockRewriter.for1_14(protocol);
new RecipeRewriter<>(protocol).register(ClientboundPackets1_16_2.DECLARE_RECIPES);
registerSetCooldown(ClientboundPackets1_16_2.COOLDOWN);
registerWindowItems(ClientboundPackets1_16_2.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
registerSetSlot(ClientboundPackets1_16_2.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
registerWindowItems(ClientboundPackets1_16_2.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY);
registerSetSlot(ClientboundPackets1_16_2.SET_SLOT, Type.ITEM1_13_2);
registerEntityEquipmentArray(ClientboundPackets1_16_2.ENTITY_EQUIPMENT);
registerTradeList(ClientboundPackets1_16_2.TRADE_LIST);
registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS, Type.ITEM1_13_2);
protocol.registerClientbound(ClientboundPackets1_16_2.UNLOCK_RECIPES, wrapper -> {
wrapper.passthrough(Type.VAR_INT);
@ -75,8 +75,8 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
blockRewriter.registerBlockChange(ClientboundPackets1_16_2.BLOCK_CHANGE);
protocol.registerClientbound(ClientboundPackets1_16_2.CHUNK_DATA, wrapper -> {
Chunk chunk = wrapper.read(new Chunk1_16_2Type());
wrapper.write(new Chunk1_16Type(), chunk);
Chunk chunk = wrapper.read(new ChunkType1_16_2());
wrapper.write(new ChunkType1_16(), chunk);
chunk.setIgnoreOldLightData(true);
for (int i = 0; i < chunk.getSections().length; i++) {
@ -132,11 +132,11 @@ 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.FLAT_VAR_INT_ITEM, Type.DOUBLE);
registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.ITEM1_13_2, Type.DOUBLE);
registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.ITEM1_13_2);
registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.ITEM1_13_2)));
}
private void handleBlockEntity(CompoundTag tag) {

Datei anzeigen

@ -36,7 +36,7 @@ public class Protocol1_16_3To1_16_4 extends BackwardsProtocol<ClientboundPackets
registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, new PacketHandlers() {
@Override
public void register() {
map(Type.FLAT_VAR_INT_ITEM);
map(Type.ITEM1_13_2);
map(Type.BOOLEAN);
handler(wrapper -> {
int slot = wrapper.read(Type.VAR_INT);

Datei anzeigen

@ -34,16 +34,16 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_16_2;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.rewriter.RecipeRewriter;
import com.viaversion.viaversion.util.CompactArrayUtil;
@ -61,23 +61,23 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
@Override
protected void registerPackets() {
BlockRewriter<ClientboundPackets1_17> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
BlockRewriter<ClientboundPackets1_17> blockRewriter = BlockRewriter.for1_14(protocol);
new RecipeRewriter<>(protocol).register(ClientboundPackets1_17.DECLARE_RECIPES);
registerSetCooldown(ClientboundPackets1_17.COOLDOWN);
registerWindowItems(ClientboundPackets1_17.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
registerWindowItems(ClientboundPackets1_17.WINDOW_ITEMS, Type.ITEM1_13_2_SHORT_ARRAY);
registerEntityEquipmentArray(ClientboundPackets1_17.ENTITY_EQUIPMENT);
registerTradeList(ClientboundPackets1_17.TRADE_LIST);
registerAdvancements(ClientboundPackets1_17.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_17.ADVANCEMENTS, Type.ITEM1_13_2);
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.FLAT_VAR_INT_ITEM);
protocol.registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
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
// set slot packets after practically every window click, since it thinks the client and server
@ -95,7 +95,7 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
byte button = wrapper.passthrough(Type.BYTE); // Button
wrapper.read(Type.SHORT); // Action id - removed
int mode = wrapper.passthrough(Type.VAR_INT); // Mode
Item clicked = handleItemToServer(wrapper.read(Type.FLAT_VAR_INT_ITEM)); // Clicked item
Item clicked = handleItemToServer(wrapper.read(Type.ITEM1_13_2)); // Clicked item
// The 1.17 client would check the entire inventory for changes before -> after a click and send the changed slots here
wrapper.write(Type.VAR_INT, 0); // Empty array of slot+item
@ -128,9 +128,9 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
Item carried = state.getLastCursorItem();
if (carried == null) {
// Expected is the carried item after clicking, old clients send the clicked one (*mostly* being the same)
wrapper.write(Type.FLAT_VAR_INT_ITEM, clicked);
wrapper.write(Type.ITEM1_13_2, clicked);
} else {
wrapper.write(Type.FLAT_VAR_INT_ITEM, carried);
wrapper.write(Type.ITEM1_13_2, carried);
}
});
}
@ -140,7 +140,7 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
short windowId = wrapper.passthrough(Type.UNSIGNED_BYTE);
short slot = wrapper.passthrough(Type.SHORT);
Item carried = wrapper.read(Type.FLAT_VAR_INT_ITEM);
Item carried = wrapper.read(Type.ITEM1_13_2);
if (carried != null && windowId == -1 && slot == -1) {
// This is related to the hack to fix click and drag ghost items above.
// After a completed drag, we have no idea how many items remain on the cursor,
@ -152,7 +152,7 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
wrapper.user().get(PlayerLastCursorItem.class).setLastCursorItem(carried);
}
wrapper.write(Type.FLAT_VAR_INT_ITEM, handleItemToClient(carried));
wrapper.write(Type.ITEM1_13_2, handleItemToClient(carried));
});
protocol.registerServerbound(ServerboundPackets1_16_2.WINDOW_CONFIRMATION, null, wrapper -> {
@ -324,8 +324,8 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
EntityTracker tracker = wrapper.user().getEntityTracker(Protocol1_16_4To1_17.class);
int currentWorldSectionHeight = tracker.currentWorldSectionHeight();
Chunk chunk = wrapper.read(new Chunk1_17Type(currentWorldSectionHeight));
wrapper.write(new Chunk1_16_2Type(), chunk);
Chunk chunk = wrapper.read(new ChunkType1_17(currentWorldSectionHeight));
wrapper.write(new ChunkType1_16_2(), chunk);
// Cut sections
int startFromSection = Math.max(0, -(tracker.currentMinY() >> 4));

Datei anzeigen

@ -32,14 +32,14 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
import com.viaversion.viaversion.rewriter.RecipeRewriter;
import com.viaversion.viaversion.util.Key;
import com.viaversion.viaversion.util.MathUtil;
@ -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.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_18.ADVANCEMENTS, Type.ITEM1_13_2);
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.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_PARTICLE, new PacketHandlers() {
@Override
@ -114,7 +114,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
} else if (mappings.isItemParticle(id)) {
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
handleItemToClient(wrapper.passthrough(Type.ITEM1_13_2));
}
int newId = protocol.getMappingData().getNewParticleId(id);
@ -169,7 +169,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
protocol.registerClientbound(ClientboundPackets1_18.CHUNK_DATA, wrapper -> {
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
final Chunk1_18Type chunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(),
final ChunkType1_18 chunkType = new ChunkType1_18(tracker.currentWorldSectionHeight(),
MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().mappedSize()),
MathUtil.ceilLog2(tracker.biomesSent()));
final Chunk oldChunk = wrapper.read(chunkType);
@ -218,7 +218,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
final Chunk chunk = new BaseChunk(oldChunk.getX(), oldChunk.getZ(), true, false, mask,
oldChunk.getSections(), biomeData, oldChunk.getHeightMap(), blockEntityTags);
wrapper.write(new Chunk1_17Type(tracker.currentWorldSectionHeight()), chunk);
wrapper.write(new ChunkType1_17(tracker.currentWorldSectionHeight()), chunk);
// Create and send light packet first
final PacketWrapper lightPacket = wrapper.create(ClientboundPackets1_17_1.UPDATE_LIGHT);

Datei anzeigen

@ -70,10 +70,10 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
wrapper.user().get(InventoryStateIds.class).setStateId(containerId, stateId);
// Length is encoded as a var int in 1.17.1
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY, wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT));
wrapper.write(Type.ITEM1_13_2_SHORT_ARRAY, wrapper.read(Type.ITEM1_13_2_ARRAY));
// Carried item - should work without adding it to the array above
Item carried = wrapper.read(Type.FLAT_VAR_INT_ITEM);
Item carried = wrapper.read(Type.ITEM1_13_2);
PlayerLastCursorItem lastCursorItem = wrapper.user().get(PlayerLastCursorItem.class);
if (lastCursorItem != null) {
@ -97,7 +97,7 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
});
registerServerbound(ServerboundPackets1_17.EDIT_BOOK, wrapper -> {
Item item = wrapper.read(Type.FLAT_VAR_INT_ITEM);
Item item = wrapper.read(Type.ITEM1_13_2);
boolean signing = wrapper.read(Type.BOOLEAN);
wrapper.passthrough(Type.VAR_INT); // Slot comes first

Datei anzeigen

@ -29,8 +29,8 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.rewriter.RecipeRewriter;
@ -44,7 +44,7 @@ public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1
@Override
protected void registerPackets() {
final BlockRewriter<ClientboundPackets1_19> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
final BlockRewriter<ClientboundPackets1_19> blockRewriter = BlockRewriter.for1_14(protocol);
new RecipeRewriter<>(protocol).register(ClientboundPackets1_19.DECLARE_RECIPES);
@ -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.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_19.ADVANCEMENTS, Type.ITEM1_13_2);
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.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
protocol.registerClientbound(ClientboundPackets1_19.TRADE_LIST, new PacketHandlers() {
@Override
@ -70,14 +70,14 @@ public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1
final int size = wrapper.read(Type.VAR_INT);
wrapper.write(Type.UNSIGNED_BYTE, (short) size);
for (int i = 0; i < size; i++) {
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // First item
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
handleItemToClient(wrapper.passthrough(Type.ITEM1_13_2)); // First item
handleItemToClient(wrapper.passthrough(Type.ITEM1_13_2)); // Result
final Item secondItem = wrapper.read(Type.FLAT_VAR_INT_ITEM);
final Item secondItem = wrapper.read(Type.ITEM1_13_2);
if (secondItem != null) {
handleItemToClient(secondItem);
wrapper.write(Type.BOOLEAN, true);
wrapper.write(Type.FLAT_VAR_INT_ITEM, secondItem);
wrapper.write(Type.ITEM1_13_2, secondItem);
} else {
wrapper.write(Type.BOOLEAN, false);
}
@ -141,7 +141,7 @@ public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1
protocol.registerClientbound(ClientboundPackets1_19.CHUNK_DATA, wrapper -> {
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
final Chunk1_18Type chunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(),
final ChunkType1_18 chunkType = new ChunkType1_18(tracker.currentWorldSectionHeight(),
MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().mappedSize()),
MathUtil.ceilLog2(tracker.biomesSent()));
final Chunk chunk = wrapper.passthrough(chunkType);

Datei anzeigen

@ -22,7 +22,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.Protocol1_19_
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ServerboundPackets1_19_1;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
import com.viaversion.viaversion.rewriter.BlockRewriter;
@ -37,22 +37,22 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter<ClientboundPacket
@Override
protected void registerPackets() {
final BlockRewriter<ClientboundPackets1_19_3> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
final BlockRewriter<ClientboundPackets1_19_3> blockRewriter = BlockRewriter.for1_14(protocol);
blockRewriter.registerBlockAction(ClientboundPackets1_19_3.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_19_3.BLOCK_CHANGE);
blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_19_3.MULTI_BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_19_3.EFFECT, 1010, 2001);
blockRewriter.registerChunkData1_19(ClientboundPackets1_19_3.CHUNK_DATA, Chunk1_18Type::new);
blockRewriter.registerChunkData1_19(ClientboundPackets1_19_3.CHUNK_DATA, ChunkType1_18::new);
blockRewriter.registerBlockEntityData(ClientboundPackets1_19_3.BLOCK_ENTITY_DATA);
registerSetCooldown(ClientboundPackets1_19_3.COOLDOWN);
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.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_19_3.ADVANCEMENTS, Type.ITEM1_13_2);
registerClickWindow1_17_1(ServerboundPackets1_19_1.CLICK_WINDOW);
registerTradeList1_19(ClientboundPackets1_19_3.TRADE_LIST);
registerCreativeInvAction(ServerboundPackets1_19_1.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_19_1.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_3.WINDOW_PROPERTY);
registerSpawnParticle1_19(ClientboundPackets1_19_3.SPAWN_PARTICLE);
@ -77,12 +77,12 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter<ClientboundPacket
wrapper.read(Type.VAR_INT); // Crafting book category
final int ingredients = wrapper.passthrough(Type.VAR_INT);
for (int j = 0; j < ingredients; j++) {
final Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
final Item[] items = wrapper.passthrough(Type.ITEM1_13_2_ARRAY); // Ingredients
for (final Item item : items) {
handleItemToClient(item);
}
}
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
handleItemToClient(wrapper.passthrough(Type.ITEM1_13_2)); // Result
break;
}
case "crafting_shaped": {
@ -90,12 +90,12 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter<ClientboundPacket
wrapper.passthrough(Type.STRING); // Group
wrapper.read(Type.VAR_INT); // Crafting book category
for (int j = 0; j < ingredients; j++) {
final Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
final Item[] items = wrapper.passthrough(Type.ITEM1_13_2_ARRAY); // Ingredients
for (final Item item : items) {
handleItemToClient(item);
}
}
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
handleItemToClient(wrapper.passthrough(Type.ITEM1_13_2)); // Result
break;
}
case "smelting":
@ -104,11 +104,11 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter<ClientboundPacket
case "smoking":
wrapper.passthrough(Type.STRING); // Group
wrapper.read(Type.VAR_INT); // Crafting book category
final Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
final Item[] items = wrapper.passthrough(Type.ITEM1_13_2_ARRAY); // Ingredients
for (final Item item : items) {
handleItemToClient(item);
}
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
handleItemToClient(wrapper.passthrough(Type.ITEM1_13_2)); // Result
wrapper.passthrough(Type.FLOAT); // EXP
wrapper.passthrough(Type.VAR_INT); // Cooking time
break;

Datei anzeigen

@ -22,7 +22,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.rewriter.RecipeRewriter1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
@ -37,12 +37,12 @@ public final class BlockItemPackets1_19_4 extends ItemRewriter<ClientboundPacket
@Override
public void registerPackets() {
final BlockRewriter<ClientboundPackets1_19_4> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
final BlockRewriter<ClientboundPackets1_19_4> blockRewriter = BlockRewriter.for1_14(protocol);
blockRewriter.registerBlockAction(ClientboundPackets1_19_4.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_19_4.BLOCK_CHANGE);
blockRewriter.registerVarLongMultiBlockChange(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.registerChunkData1_19(ClientboundPackets1_19_4.CHUNK_DATA, ChunkType1_18::new);
blockRewriter.registerBlockEntityData(ClientboundPackets1_19_4.BLOCK_ENTITY_DATA);
protocol.registerClientbound(ClientboundPackets1_19_4.OPEN_WINDOW, new PacketHandlers() {
@ -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.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_19_4.ADVANCEMENTS, Type.ITEM1_13_2);
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.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_19_3.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_4.WINDOW_PROPERTY);
registerSpawnParticle1_19(ClientboundPackets1_19_4.SPAWN_PARTICLE);
@ -84,7 +84,7 @@ public final class BlockItemPackets1_19_4 extends ItemRewriter<ClientboundPacket
for (int i = 0; i < ingredients; i++) {
handleIngredient(wrapper);
}
rewrite(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
rewrite(wrapper.passthrough(Type.ITEM1_13_2)); // Result
// Remove notification boolean
wrapper.read(Type.BOOLEAN);
@ -99,11 +99,11 @@ public final class BlockItemPackets1_19_4 extends ItemRewriter<ClientboundPacket
if (cutType.equals("smithing_transform") || cutType.equals("smithing_trim")) {
newSize--;
wrapper.read(Type.STRING); // Recipe identifier
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Template
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Base
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Additions
wrapper.read(Type.ITEM1_13_2_ARRAY); // Template
wrapper.read(Type.ITEM1_13_2_ARRAY); // Base
wrapper.read(Type.ITEM1_13_2_ARRAY); // Additions
if (cutType.equals("smithing_transform")) {
wrapper.read(Type.FLAT_VAR_INT_ITEM); // Result
wrapper.read(Type.ITEM1_13_2); // Result
}
continue;
} else if (cutType.equals("crafting_decorated_pot")) {

Datei anzeigen

@ -26,11 +26,11 @@ import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
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.ServerboundPackets1_19_4;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.rewriter.RecipeRewriter1_19_4;
@ -51,7 +51,7 @@ public final class BlockItemPackets1_20 extends ItemRewriter<ClientboundPackets1
@Override
public void registerPackets() {
final BlockRewriter<ClientboundPackets1_19_4> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
final BlockRewriter<ClientboundPackets1_19_4> blockRewriter = BlockRewriter.for1_14(protocol);
blockRewriter.registerBlockAction(ClientboundPackets1_19_4.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_19_4.BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_19_4.EFFECT, 1010, 2001);
@ -60,7 +60,7 @@ public final class BlockItemPackets1_20 extends ItemRewriter<ClientboundPackets1
protocol.registerClientbound(ClientboundPackets1_19_4.CHUNK_DATA, new PacketHandlers() {
@Override
protected void register() {
handler(blockRewriter.chunkDataHandler1_19(Chunk1_18Type::new, BlockItemPackets1_20.this::handleBlockEntity));
handler(blockRewriter.chunkDataHandler1_19(ChunkType1_18::new, BlockItemPackets1_20.this::handleBlockEntity));
create(Type.BOOLEAN, true); // Trust edges
}
});
@ -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.FLAT_VAR_INT_ITEM);
registerCreativeInvAction(ServerboundPackets1_19_4.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13_2);
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_4.WINDOW_PROPERTY);
registerSpawnParticle1_19(ClientboundPackets1_19_4.SPAWN_PARTICLE);
@ -109,7 +109,7 @@ public final class BlockItemPackets1_20 extends ItemRewriter<ClientboundPackets1
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.COMPONENT); // Title
wrapper.passthrough(Type.COMPONENT); // Description
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
handleItemToClient(wrapper.passthrough(Type.ITEM1_13_2)); // Icon
wrapper.passthrough(Type.VAR_INT); // Frame type
int flags = wrapper.passthrough(Type.INT); // Flags
if ((flags & 1) != 0) {

Datei anzeigen

@ -20,10 +20,10 @@ package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter;
import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter.RecipeRewriter1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_20_2;
import com.viaversion.viaversion.rewriter.BlockRewriter;
public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter<ClientboundPackets1_20_2, ServerboundPackets1_20_2, Protocol1_20_2To1_20_3> {

Datei anzeigen

@ -31,15 +31,15 @@ import com.viaversion.viaversion.api.minecraft.metadata.ChunkPosition;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_18;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter.RecipeRewriter1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.util.PotionEffects;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.util.Key;
@ -54,7 +54,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
@Override
public void registerPackets() {
final BlockRewriter<ClientboundPackets1_20_2> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
final BlockRewriter<ClientboundPackets1_20_2> blockRewriter = BlockRewriter.for1_14(protocol);
blockRewriter.registerBlockAction(ClientboundPackets1_20_2.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_20_2.BLOCK_CHANGE);
blockRewriter.registerVarLongMultiBlockChange1_20(ClientboundPackets1_20_2.MULTI_BLOCK_CHANGE);
@ -93,7 +93,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
MathUtil.ceilLog2(tracker.biomesSent()));
final Chunk chunk = wrapper.read(chunkType);
final Type<Chunk> newChunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(),
final Type<Chunk> newChunkType = new ChunkType1_18(tracker.currentWorldSectionHeight(),
MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().mappedSize()),
MathUtil.ceilLog2(tracker.biomesSent()));
wrapper.write(newChunkType, chunk);
@ -133,8 +133,8 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
handleItemToClient(item);
}
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
wrapper.write(Type.FLAT_VAR_INT_ITEM, handleItemToClient(wrapper.read(Type.ITEM1_20_2))); // Carried item
wrapper.write(Type.ITEM1_13_2_ARRAY, items);
wrapper.write(Type.ITEM1_13_2, handleItemToClient(wrapper.read(Type.ITEM1_20_2))); // Carried item
});
}
});
@ -144,7 +144,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
map(Type.UNSIGNED_BYTE); // Window id
map(Type.VAR_INT); // State id
map(Type.SHORT); // Slot id
handler(wrapper -> wrapper.write(Type.FLAT_VAR_INT_ITEM, handleItemToClient(wrapper.read(Type.ITEM1_20_2))));
handler(wrapper -> wrapper.write(Type.ITEM1_13_2, handleItemToClient(wrapper.read(Type.ITEM1_20_2))));
}
});
protocol.registerClientbound(ClientboundPackets1_20_2.ADVANCEMENTS, wrapper -> {
@ -162,7 +162,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.COMPONENT); // Title
wrapper.passthrough(Type.COMPONENT); // Description
wrapper.write(Type.FLAT_VAR_INT_ITEM, handleItemToClient(wrapper.read(Type.ITEM1_20_2))); // Icon
wrapper.write(Type.ITEM1_13_2, handleItemToClient(wrapper.read(Type.ITEM1_20_2))); // Icon
wrapper.passthrough(Type.VAR_INT); // Frame type
final int flags = wrapper.passthrough(Type.INT); // Flags
if ((flags & 1) != 0) {
@ -190,7 +190,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
byte slot;
do {
slot = wrapper.passthrough(Type.BYTE);
wrapper.write(Type.FLAT_VAR_INT_ITEM, handleItemToClient(wrapper.read(Type.ITEM1_20_2)));
wrapper.write(Type.ITEM1_13_2, handleItemToClient(wrapper.read(Type.ITEM1_20_2)));
} while ((slot & 0xFFFFFF80) != 0);
});
}
@ -209,11 +209,11 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
final int length = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < length; i++) {
wrapper.passthrough(Type.SHORT); // Slot
wrapper.write(Type.ITEM1_20_2, handleItemToServer(wrapper.read(Type.FLAT_VAR_INT_ITEM)));
wrapper.write(Type.ITEM1_20_2, handleItemToServer(wrapper.read(Type.ITEM1_13_2)));
}
// Carried item
wrapper.write(Type.ITEM1_20_2, handleItemToServer(wrapper.read(Type.FLAT_VAR_INT_ITEM)));
wrapper.write(Type.ITEM1_20_2, handleItemToServer(wrapper.read(Type.ITEM1_13_2)));
});
}
});
@ -221,9 +221,9 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
wrapper.passthrough(Type.VAR_INT); // Container id
final int size = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < size; i++) {
wrapper.write(Type.FLAT_VAR_INT_ITEM, handleItemToClient(wrapper.read(Type.ITEM1_20_2))); // Input
wrapper.write(Type.FLAT_VAR_INT_ITEM, handleItemToClient(wrapper.read(Type.ITEM1_20_2))); // Output
wrapper.write(Type.FLAT_VAR_INT_ITEM, handleItemToClient(wrapper.read(Type.ITEM1_20_2))); // Second Item
wrapper.write(Type.ITEM1_13_2, handleItemToClient(wrapper.read(Type.ITEM1_20_2))); // Input
wrapper.write(Type.ITEM1_13_2, handleItemToClient(wrapper.read(Type.ITEM1_20_2))); // Output
wrapper.write(Type.ITEM1_13_2, handleItemToClient(wrapper.read(Type.ITEM1_20_2))); // Second Item
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
wrapper.passthrough(Type.INT); // Number of tools uses
@ -238,7 +238,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
@Override
public void register() {
map(Type.SHORT); // 0 - Slot
handler(wrapper -> wrapper.write(Type.ITEM1_20_2, handleItemToServer(wrapper.read(Type.FLAT_VAR_INT_ITEM)))); // 1 - Clicked Item
handler(wrapper -> wrapper.write(Type.ITEM1_20_2, handleItemToServer(wrapper.read(Type.ITEM1_13_2)))); // 1 - Clicked Item
}
});
protocol.registerClientbound(ClientboundPackets1_20_2.SPAWN_PARTICLE, new PacketHandlers() {
@ -261,7 +261,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
final int data = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewBlockStateId(data));
} else if (mappings.isItemParticle(id)) {
wrapper.write(Type.FLAT_VAR_INT_ITEM, handleItemToClient(wrapper.read(Type.ITEM1_20_2)));
wrapper.write(Type.ITEM1_13_2, handleItemToClient(wrapper.read(Type.ITEM1_20_2)));
}
});
}
@ -276,7 +276,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
final Item result = wrapper.read(itemType());
rewrite(result);
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
wrapper.write(Type.ITEM1_13_2, result);
}
@Override
@ -287,7 +287,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
final Item result = wrapper.read(itemType());
rewrite(result);
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
wrapper.write(Type.ITEM1_13_2, result);
wrapper.passthrough(Type.FLOAT); // EXP
wrapper.passthrough(Type.VAR_INT); // Cooking time
@ -304,7 +304,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
final Item result = wrapper.read(itemType());
rewrite(result);
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
wrapper.write(Type.ITEM1_13_2, result);
wrapper.passthrough(Type.BOOLEAN); // Show notification
}
@ -316,7 +316,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
final Item result = wrapper.read(itemType());
rewrite(result);
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
wrapper.write(Type.ITEM1_13_2, result);
}
@Override
@ -326,7 +326,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
final Item result = wrapper.read(itemType());
rewrite(result);
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
wrapper.write(Type.ITEM1_13_2, result);
}
@Override
@ -337,13 +337,13 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
final Item result = wrapper.read(itemType());
rewrite(result);
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
wrapper.write(Type.ITEM1_13_2, result);
}
@Override
protected void handleIngredient(final PacketWrapper wrapper) throws Exception {
final Item[] items = wrapper.read(itemArrayType());
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
wrapper.write(Type.ITEM1_13_2_ARRAY, items);
for (final Item item : items) {
rewrite(item);
}

Datei anzeigen

@ -19,19 +19,19 @@ package com.viaversion.viabackwards.protocol.protocol1_9_1_2to1_9_3_4;
import com.viaversion.viabackwards.protocol.protocol1_9_1_2to1_9_3_4.chunks.BlockEntity;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_1;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.protocols.protocol1_9_1to1_9.types.Chunk1_9_1_2Type;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
@ -46,18 +46,18 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol<ClientboundPacket
registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION); //Position
map(Type.POSITION1_8); //Position
map(Type.UNSIGNED_BYTE); //Type
map(Type.NAMED_COMPOUND_TAG); //NBT
handler(wrapper -> {
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 9) {
Position position = wrapper.get(Type.POSITION, 0);
Position position = wrapper.get(Type.POSITION1_8, 0);
CompoundTag tag = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
wrapper.clearPacket(); //Clear the packet
wrapper.setPacketType(ClientboundPackets1_9.UPDATE_SIGN);
wrapper.write(Type.POSITION, position); // Position
wrapper.write(Type.POSITION1_8, position); // Position
for (int i = 1; i < 5; i++) {
// Should technically be written as COMPONENT, but left as String for simplification/to remove redundant wrapping for VR
Tag textTag = tag.get("Text" + i);
@ -72,8 +72,8 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol<ClientboundPacket
registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk1_9_3_4Type newType = new Chunk1_9_3_4Type(clientWorld);
Chunk1_9_1_2Type oldType = new Chunk1_9_1_2Type(clientWorld); // Get the old type to not write Block Entities
ChunkType1_9_3 newType = new ChunkType1_9_3(clientWorld);
ChunkType1_9_1 oldType = new ChunkType1_9_1(clientWorld); // Get the old type to not write Block Entities
Chunk chunk = wrapper.read(newType);
wrapper.write(oldType, chunk);

Datei anzeigen

@ -77,7 +77,7 @@ public class BlockEntity {
private static void updateBlockEntity(Position pos, short id, CompoundTag tag, UserConnection connection) throws Exception {
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, null, connection);
wrapper.write(Type.POSITION, pos);
wrapper.write(Type.POSITION1_8, pos);
wrapper.write(Type.UNSIGNED_BYTE, id);
wrapper.write(Type.NAMED_COMPOUND_TAG, tag);
wrapper.scheduleSend(Protocol1_9_1_2To1_9_3_4.class, false);

Datei anzeigen

@ -24,6 +24,7 @@ import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.packets.BlockItemPackets1_10;
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.packets.EntityPackets1_10;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -32,7 +33,6 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {

Datei anzeigen

@ -21,14 +21,14 @@ package com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.packets;
import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_3_4Type;
public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPackets1_9_3, ServerboundPackets1_9_3, Protocol1_9_4To1_10> {
@ -38,11 +38,11 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
@Override
protected void registerPackets() {
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM);
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM1_8);
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM1_8_ARRAY);
// Entity Equipment Packet
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM1_8);
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
@Override
@ -55,12 +55,12 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Input Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Output Item
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
if (secondItem) {
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Second Item
wrapper.write(Type.ITEM1_8, handleItemToClient(wrapper.read(Type.ITEM1_8))); // Second Item
}
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
@ -72,13 +72,13 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
}
});
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM1_8);
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM1_8);
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
ChunkType1_9_3 type = new ChunkType1_9_3(clientWorld);
Chunk chunk = wrapper.passthrough(type);
handleChunk(chunk);
@ -88,7 +88,7 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketHandlers() {
@Override
public void register() {
map(Type.POSITION); // 0 - Block Position
map(Type.POSITION1_8); // 0 - Block Position
map(Type.VAR_INT); // 1 - Block
handler(wrapper -> {
@ -116,7 +116,7 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
// Rewrite metadata items
protocol.getEntityRewriter().filter().handler((event, meta) -> {
if (meta.metaType().type().equals(Type.ITEM)) // Is Item
if (meta.metaType().type().equals(Type.ITEM1_8)) // Is Item
meta.setValue(handleItemToClient((Item) meta.getValue()));
});

Datei anzeigen

@ -20,10 +20,10 @@ package com.viaversion.viabackwards.template.protocol.rewriter;
import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
import com.viaversion.viabackwards.template.protocol.Protocol1_98To_99;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter.RecipeRewriter1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_20_2;
import com.viaversion.viaversion.rewriter.BlockRewriter;
// To replace if needed: