Search in sources :

Example 36 with Item

use of com.viaversion.viaversion.api.minecraft.item.Item in project ViaVersion by ViaVersion.

the class WorldPackets method register.

public static void register(Protocol protocol) {
    protocol.registerClientbound(ClientboundPackets1_8.UPDATE_SIGN, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Sign Position
            map(Type.POSITION);
            // 1 - Sign Line (json)
            map(Type.STRING, Protocol1_9To1_8.FIX_JSON);
            // 2 - Sign Line (json)
            map(Type.STRING, Protocol1_9To1_8.FIX_JSON);
            // 3 - Sign Line (json)
            map(Type.STRING, Protocol1_9To1_8.FIX_JSON);
            // 4 - Sign Line (json)
            map(Type.STRING, Protocol1_9To1_8.FIX_JSON);
        }
    });
    protocol.registerClientbound(ClientboundPackets1_8.EFFECT, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Effect ID
            map(Type.INT);
            // 1 - Position
            map(Type.POSITION);
            // 2 - Data
            map(Type.INT);
            // 3 - Disable relative volume
            map(Type.BOOLEAN);
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int id = wrapper.get(Type.INT, 0);
                    id = Effect.getNewId(id);
                    wrapper.set(Type.INT, 0, id);
                }
            });
            // Rewrite potion effect as it changed to use a dynamic registry
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int id = wrapper.get(Type.INT, 0);
                    if (id == 2002) {
                        int data = wrapper.get(Type.INT, 1);
                        int newData = ItemRewriter.getNewEffectID(data);
                        wrapper.set(Type.INT, 1, newData);
                    }
                }
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_8.NAMED_SOUND, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Sound Name
            map(Type.STRING);
            // 1 - Sound Category ID
            // Everything else get's written through
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    String name = wrapper.get(Type.STRING, 0);
                    SoundEffect effect = SoundEffect.getByName(name);
                    int catid = 0;
                    String newname = name;
                    if (effect != null) {
                        catid = effect.getCategory().getId();
                        newname = effect.getNewName();
                    }
                    wrapper.set(Type.STRING, 0, newname);
                    // Write Category ID
                    wrapper.write(Type.VAR_INT, catid);
                    if (effect != null && effect.isBreaksound()) {
                        EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
                        // Position X
                        int x = wrapper.passthrough(Type.INT);
                        // Position Y
                        int y = wrapper.passthrough(Type.INT);
                        // Position Z
                        int z = wrapper.passthrough(Type.INT);
                        if (tracker.interactedBlockRecently((int) Math.floor(x / 8.0), (int) Math.floor(y / 8.0), (int) Math.floor(z / 8.0))) {
                            wrapper.cancel();
                        }
                    }
                }
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_8.CHUNK_DATA, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
                    ClientChunks clientChunks = wrapper.user().get(ClientChunks.class);
                    Chunk chunk = wrapper.read(new Chunk1_8Type(clientWorld));
                    long chunkHash = ClientChunks.toLong(chunk.getX(), chunk.getZ());
                    // Check if the chunk should be handled as an unload packet
                    if (chunk.isFullChunk() && chunk.getBitmask() == 0) {
                        wrapper.setPacketType(ClientboundPackets1_9.UNLOAD_CHUNK);
                        wrapper.write(Type.INT, chunk.getX());
                        wrapper.write(Type.INT, chunk.getZ());
                        // Remove commandBlocks on chunk unload
                        CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class);
                        provider.unloadChunk(wrapper.user(), chunk.getX(), chunk.getZ());
                        clientChunks.getLoadedChunks().remove(chunkHash);
                        // Unload the empty chunks
                        if (Via.getConfig().isChunkBorderFix()) {
                            for (BlockFace face : BlockFace.HORIZONTAL) {
                                int chunkX = chunk.getX() + face.modX();
                                int chunkZ = chunk.getZ() + face.modZ();
                                if (!clientChunks.getLoadedChunks().contains(ClientChunks.toLong(chunkX, chunkZ))) {
                                    PacketWrapper unloadChunk = wrapper.create(ClientboundPackets1_9.UNLOAD_CHUNK);
                                    unloadChunk.write(Type.INT, chunkX);
                                    unloadChunk.write(Type.INT, chunkZ);
                                    unloadChunk.send(Protocol1_9To1_8.class);
                                }
                            }
                        }
                    } else {
                        Type<Chunk> chunkType = new Chunk1_9_1_2Type(clientWorld);
                        wrapper.write(chunkType, chunk);
                        clientChunks.getLoadedChunks().add(chunkHash);
                        // Send empty chunks surrounding the loaded chunk to force 1.9+ clients to render the new chunk
                        if (Via.getConfig().isChunkBorderFix()) {
                            for (BlockFace face : BlockFace.HORIZONTAL) {
                                int chunkX = chunk.getX() + face.modX();
                                int chunkZ = chunk.getZ() + face.modZ();
                                if (!clientChunks.getLoadedChunks().contains(ClientChunks.toLong(chunkX, chunkZ))) {
                                    PacketWrapper emptyChunk = wrapper.create(ClientboundPackets1_9.CHUNK_DATA);
                                    Chunk c = new BaseChunk(chunkX, chunkZ, true, false, 0, new ChunkSection[16], new int[256], new ArrayList<>());
                                    emptyChunk.write(chunkType, c);
                                    emptyChunk.send(Protocol1_9To1_8.class);
                                }
                            }
                        }
                    }
                }
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_8.MAP_BULK_CHUNK, null, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> {
                // Cancel the packet from being sent
                wrapper.cancel();
                ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
                ClientChunks clientChunks = wrapper.user().get(ClientChunks.class);
                Chunk[] chunks = wrapper.read(new ChunkBulk1_8Type(clientWorld));
                Type<Chunk> chunkType = new Chunk1_9_1_2Type(clientWorld);
                // Split into multiple chunk packets
                for (Chunk chunk : chunks) {
                    PacketWrapper chunkData = wrapper.create(ClientboundPackets1_9.CHUNK_DATA);
                    chunkData.write(chunkType, chunk);
                    chunkData.send(Protocol1_9To1_8.class);
                    clientChunks.getLoadedChunks().add(ClientChunks.toLong(chunk.getX(), chunk.getZ()));
                    // Send empty chunks surrounding the loaded chunk to force 1.9+ clients to render the new chunk
                    if (Via.getConfig().isChunkBorderFix()) {
                        for (BlockFace face : BlockFace.HORIZONTAL) {
                            int chunkX = chunk.getX() + face.modX();
                            int chunkZ = chunk.getZ() + face.modZ();
                            if (!clientChunks.getLoadedChunks().contains(ClientChunks.toLong(chunkX, chunkZ))) {
                                PacketWrapper emptyChunk = wrapper.create(ClientboundPackets1_9.CHUNK_DATA);
                                Chunk c = new BaseChunk(chunkX, chunkZ, true, false, 0, new ChunkSection[16], new int[256], new ArrayList<>());
                                emptyChunk.write(chunkType, c);
                                emptyChunk.send(Protocol1_9To1_8.class);
                            }
                        }
                    }
                }
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_8.BLOCK_ENTITY_DATA, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Block Position
            map(Type.POSITION);
            // 1 - Action
            map(Type.UNSIGNED_BYTE);
            // 2 - NBT (Might not be present)
            map(Type.NBT);
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int action = wrapper.get(Type.UNSIGNED_BYTE, 0);
                    if (action == 1) {
                        // Update Spawner
                        CompoundTag tag = wrapper.get(Type.NBT, 0);
                        if (tag != null) {
                            if (tag.contains("EntityId")) {
                                String entity = (String) tag.get("EntityId").getValue();
                                CompoundTag spawn = new CompoundTag();
                                spawn.put("id", new StringTag(entity));
                                tag.put("SpawnData", spawn);
                            } else {
                                // EntityID does not exist
                                CompoundTag spawn = new CompoundTag();
                                // Make spawners show up as empty when no EntityId is given.
                                spawn.put("id", new StringTag("AreaEffectCloud"));
                                tag.put("SpawnData", spawn);
                            }
                        }
                    }
                    if (action == 2) {
                        // Update Command Block
                        CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class);
                        provider.addOrUpdateBlock(wrapper.user(), wrapper.get(Type.POSITION, 0), wrapper.get(Type.NBT, 0));
                        // To prevent window issues don't send updates
                        wrapper.cancel();
                    }
                }
            });
        }
    });
    /* Incoming Packets */
    protocol.registerServerbound(ServerboundPackets1_9.UPDATE_SIGN, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Sign Position
            map(Type.POSITION);
            // 1 - Sign Line (json)
            map(Type.STRING, Protocol1_9To1_8.FIX_JSON);
            // 2 - Sign Line (json)
            map(Type.STRING, Protocol1_9To1_8.FIX_JSON);
            // 3 - Sign Line (json)
            map(Type.STRING, Protocol1_9To1_8.FIX_JSON);
            // 4 - Sign Line (json)
            map(Type.STRING, Protocol1_9To1_8.FIX_JSON);
        }
    });
    protocol.registerServerbound(ServerboundPackets1_9.PLAYER_DIGGING, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Action
            map(Type.VAR_INT);
            // Position
            map(Type.POSITION);
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int status = wrapper.get(Type.VAR_INT, 0);
                    if (status == 6)
                        wrapper.cancel();
                }
            });
            // Blocking
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int status = wrapper.get(Type.VAR_INT, 0);
                    if (status == 5 || status == 4 || status == 3) {
                        EntityTracker1_9 entityTracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
                        if (entityTracker.isBlocking()) {
                            entityTracker.setBlocking(false);
                            if (!Via.getConfig().isShowShieldWhenSwordInHand()) {
                                entityTracker.setSecondHand(null);
                            }
                        }
                    }
                }
            });
        }
    });
    protocol.registerServerbound(ServerboundPackets1_9.USE_ITEM, null, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int hand = wrapper.read(Type.VAR_INT);
                    // Wipe the input buffer
                    wrapper.clearInputBuffer();
                    // First set this packet ID to Block placement
                    wrapper.setId(0x08);
                    wrapper.write(Type.POSITION, new Position(-1, (short) -1, -1));
                    wrapper.write(Type.UNSIGNED_BYTE, (short) 255);
                    // Write item in hand
                    Item item = Protocol1_9To1_8.getHandItem(wrapper.user());
                    // Blocking patch
                    if (Via.getConfig().isShieldBlocking()) {
                        EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
                        // Check if the shield is already there or if we have to give it here
                        boolean showShieldWhenSwordInHand = Via.getConfig().isShowShieldWhenSwordInHand();
                        // Method to identify the sword in hand
                        boolean isSword = showShieldWhenSwordInHand ? tracker.hasSwordInHand() : item != null && Protocol1_9To1_8.isSword(item.identifier());
                        if (isSword) {
                            if (hand == 0) {
                                if (!tracker.isBlocking()) {
                                    tracker.setBlocking(true);
                                    // Check if the shield is already in the offhand
                                    if (!showShieldWhenSwordInHand && tracker.getItemInSecondHand() == null) {
                                        // Set shield in offhand when interacting with main hand
                                        Item shield = new DataItem(442, (byte) 1, (short) 0, null);
                                        tracker.setSecondHand(shield);
                                    }
                                }
                            }
                            // Use the main hand to trigger the blocking
                            boolean blockUsingMainHand = Via.getConfig().isNoDelayShieldBlocking() && !showShieldWhenSwordInHand;
                            if (blockUsingMainHand && hand == 1 || !blockUsingMainHand && hand == 0) {
                                wrapper.cancel();
                            }
                        } else {
                            if (!showShieldWhenSwordInHand) {
                                // Remove the shield from the offhand
                                tracker.setSecondHand(null);
                            }
                            tracker.setBlocking(false);
                        }
                    }
                    wrapper.write(Type.ITEM, item);
                    wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
                    wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
                    wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
                }
            });
        }
    });
    protocol.registerServerbound(ServerboundPackets1_9.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Position
            map(Type.POSITION);
            // 1 - Block Face
            map(Type.VAR_INT, Type.UNSIGNED_BYTE);
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    // 2 - Hand
                    final int hand = wrapper.read(Type.VAR_INT);
                    if (hand != 0)
                        wrapper.cancel();
                }
            });
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    Item item = Protocol1_9To1_8.getHandItem(wrapper.user());
                    // 3 - Item
                    wrapper.write(Type.ITEM, item);
                }
            });
            // 4 - X
            map(Type.UNSIGNED_BYTE);
            // 5 - Y
            map(Type.UNSIGNED_BYTE);
            // 6 - Z
            map(Type.UNSIGNED_BYTE);
            // Register block place to fix sounds
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int face = wrapper.get(Type.UNSIGNED_BYTE, 0);
                    if (face == 255)
                        return;
                    Position p = wrapper.get(Type.POSITION, 0);
                    int x = p.x();
                    int y = p.y();
                    int z = p.z();
                    switch(face) {
                        case 0:
                            y--;
                            break;
                        case 1:
                            y++;
                            break;
                        case 2:
                            z--;
                            break;
                        case 3:
                            z++;
                            break;
                        case 4:
                            x--;
                            break;
                        case 5:
                            x++;
                            break;
                    }
                    EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
                    tracker.addBlockInteraction(new Position(x, y, z));
                }
            });
            // Handle CommandBlocks
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class);
                    Position pos = wrapper.get(Type.POSITION, 0);
                    Optional<CompoundTag> tag = provider.get(wrapper.user(), pos);
                    // Send the Update Block Entity packet if present
                    if (tag.isPresent()) {
                        PacketWrapper updateBlockEntity = PacketWrapper.create(ClientboundPackets1_9.BLOCK_ENTITY_DATA, null, wrapper.user());
                        updateBlockEntity.write(Type.POSITION, pos);
                        updateBlockEntity.write(Type.UNSIGNED_BYTE, (short) 2);
                        updateBlockEntity.write(Type.NBT, tag.get());
                        updateBlockEntity.scheduleSend(Protocol1_9To1_8.class);
                    }
                }
            });
        }
    });
}
Also used : PacketHandler(com.viaversion.viaversion.api.protocol.remapper.PacketHandler) Effect(com.viaversion.viaversion.protocols.protocol1_9to1_8.sounds.Effect) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) Item(com.viaversion.viaversion.api.minecraft.item.Item) CommandBlockProvider(com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CommandBlockProvider) ArrayList(java.util.ArrayList) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) Type(com.viaversion.viaversion.api.type.Type) Chunk(com.viaversion.viaversion.api.minecraft.chunks.Chunk) Protocol1_9To1_8(com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8) EntityTracker1_9(com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) DataItem(com.viaversion.viaversion.api.minecraft.item.DataItem) BlockFace(com.viaversion.viaversion.api.minecraft.BlockFace) Chunk1_8Type(com.viaversion.viaversion.protocols.protocol1_9to1_8.types.Chunk1_8Type) ClientboundPackets1_8(com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8) ItemRewriter(com.viaversion.viaversion.protocols.protocol1_9to1_8.ItemRewriter) SoundEffect(com.viaversion.viaversion.protocols.protocol1_9to1_8.sounds.SoundEffect) Nullable(org.checkerframework.checker.nullness.qual.Nullable) ClientChunks(com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.ClientChunks) Position(com.viaversion.viaversion.api.minecraft.Position) Chunk1_9_1_2Type(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type) BaseChunk(com.viaversion.viaversion.api.minecraft.chunks.BaseChunk) ClientWorld(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld) Protocol(com.viaversion.viaversion.api.protocol.Protocol) ChunkBulk1_8Type(com.viaversion.viaversion.protocols.protocol1_9to1_8.types.ChunkBulk1_8Type) Via(com.viaversion.viaversion.api.Via) StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) ServerboundPackets1_9(com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9) Optional(java.util.Optional) ChunkSection(com.viaversion.viaversion.api.minecraft.chunks.ChunkSection) ClientboundPackets1_9(com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9) StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) ClientChunks(com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.ClientChunks) DataItem(com.viaversion.viaversion.api.minecraft.item.DataItem) BlockFace(com.viaversion.viaversion.api.minecraft.BlockFace) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) ArrayList(java.util.ArrayList) CommandBlockProvider(com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.CommandBlockProvider) ChunkBulk1_8Type(com.viaversion.viaversion.protocols.protocol1_9to1_8.types.ChunkBulk1_8Type) Item(com.viaversion.viaversion.api.minecraft.item.Item) DataItem(com.viaversion.viaversion.api.minecraft.item.DataItem) Chunk1_9_1_2Type(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) SoundEffect(com.viaversion.viaversion.protocols.protocol1_9to1_8.sounds.SoundEffect) BaseChunk(com.viaversion.viaversion.api.minecraft.chunks.BaseChunk) EntityTracker1_9(com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9) Position(com.viaversion.viaversion.api.minecraft.Position) Chunk(com.viaversion.viaversion.api.minecraft.chunks.Chunk) BaseChunk(com.viaversion.viaversion.api.minecraft.chunks.BaseChunk) Chunk1_8Type(com.viaversion.viaversion.protocols.protocol1_9to1_8.types.Chunk1_8Type) Type(com.viaversion.viaversion.api.type.Type) Chunk1_8Type(com.viaversion.viaversion.protocols.protocol1_9to1_8.types.Chunk1_8Type) Chunk1_9_1_2Type(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type) ChunkBulk1_8Type(com.viaversion.viaversion.protocols.protocol1_9to1_8.types.ChunkBulk1_8Type) PacketHandler(com.viaversion.viaversion.api.protocol.remapper.PacketHandler) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) ClientWorld(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld) ChunkSection(com.viaversion.viaversion.api.minecraft.chunks.ChunkSection) Protocol1_9To1_8(com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8)

Example 37 with Item

use of com.viaversion.viaversion.api.minecraft.item.Item in project ViaVersion by ViaVersion.

the class InventoryPackets method registerPackets.

@Override
public void registerPackets() {
    registerSetCooldown(ClientboundPackets1_16_2.COOLDOWN);
    registerWindowItems(ClientboundPackets1_16_2.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
    registerTradeList(ClientboundPackets1_16_2.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
    registerSetSlot(ClientboundPackets1_16_2.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
    registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
    registerEntityEquipmentArray(ClientboundPackets1_16_2.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
    registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
    new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_16_2.DECLARE_RECIPES);
    registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
    protocol.registerServerbound(ServerboundPackets1_17.EDIT_BOOK, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
        }
    });
    protocol.registerServerbound(ServerboundPackets1_17.CLICK_WINDOW, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Window Id
            map(Type.UNSIGNED_BYTE);
            // Slot
            map(Type.SHORT);
            // Button
            map(Type.BYTE);
            // Action id - doesn't matter, as the sent out confirmation packet will be cancelled
            handler(wrapper -> wrapper.write(Type.SHORT, (short) 0));
            // Action
            map(Type.VAR_INT);
            handler(wrapper -> {
                // Affected items - throw them away!
                int length = wrapper.read(Type.VAR_INT);
                for (int i = 0; i < length; i++) {
                    // Slot
                    wrapper.read(Type.SHORT);
                    wrapper.read(Type.FLAT_VAR_INT_ITEM);
                }
                // 1.17 clients send the then carried item, but 1.16 expects the clicked one
                Item item = wrapper.read(Type.FLAT_VAR_INT_ITEM);
                int action = wrapper.get(Type.VAR_INT, 0);
                if (action == 5 || action == 1) {
                    // Quick craft (= dragging / mouse movement while clicking on an empty slot)
                    // OR Quick move (= shift click to move a whole stack to the other inventory)
                    // The server always expects an empty item here
                    item = null;
                } else {
                    // Use the item sent
                    handleItemToServer(item);
                }
                wrapper.write(Type.FLAT_VAR_INT_ITEM, item);
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_16_2.WINDOW_CONFIRMATION, null, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> {
                short inventoryId = wrapper.read(Type.UNSIGNED_BYTE);
                short confirmationId = wrapper.read(Type.SHORT);
                boolean accepted = wrapper.read(Type.BOOLEAN);
                if (!accepted) {
                    // Use the new ping packet to replace the removed acknowledgement, extra bit for fast dismissal
                    int id = (1 << 30) | (inventoryId << 16) | (confirmationId & 0xFFFF);
                    wrapper.user().get(InventoryAcknowledgements.class).addId(id);
                    PacketWrapper pingPacket = wrapper.create(ClientboundPackets1_17.PING);
                    pingPacket.write(Type.INT, id);
                    pingPacket.send(Protocol1_17To1_16_4.class);
                }
                wrapper.cancel();
            });
        }
    });
    // New pong packet
    protocol.registerServerbound(ServerboundPackets1_17.PONG, null, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> {
                int id = wrapper.read(Type.INT);
                // Check extra bit for fast dismissal
                if ((id & (1 << 30)) != 0 && wrapper.user().get(InventoryAcknowledgements.class).removeId(id)) {
                    // Decode our requested inventory acknowledgement
                    short inventoryId = (short) ((id >> 16) & 0xFF);
                    short confirmationId = (short) (id & 0xFFFF);
                    PacketWrapper packet = wrapper.create(ServerboundPackets1_16_2.WINDOW_CONFIRMATION);
                    packet.write(Type.UNSIGNED_BYTE, inventoryId);
                    packet.write(Type.SHORT, confirmationId);
                    // Accept
                    packet.write(Type.BOOLEAN, true);
                    packet.sendToServer(Protocol1_17To1_16_4.class);
                }
                wrapper.cancel();
            });
        }
    });
}
Also used : PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) ClientboundPackets1_17(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17) Protocol1_17To1_16_4(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4) ItemRewriter(com.viaversion.viaversion.rewriter.ItemRewriter) Type(com.viaversion.viaversion.api.type.Type) ServerboundPackets1_16_2(com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2) InventoryAcknowledgements(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.storage.InventoryAcknowledgements) ServerboundPackets1_17(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) Item(com.viaversion.viaversion.api.minecraft.item.Item) RecipeRewriter1_16(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16) ClientboundPackets1_16_2(com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2) InventoryAcknowledgements(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.storage.InventoryAcknowledgements) Item(com.viaversion.viaversion.api.minecraft.item.Item) Protocol1_17To1_16_4(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4) RecipeRewriter1_16(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper)

Example 38 with Item

use of com.viaversion.viaversion.api.minecraft.item.Item in project ViaVersion by ViaVersion.

the class InventoryPackets method registerPackets.

@Override
public void registerPackets() {
    // clear cursor item to prevent client to try dropping it during navigation between multiple inventories causing arm swing
    PacketHandler cursorRemapper = wrapper -> {
        PacketWrapper clearPacket = wrapper.create(ClientboundPackets1_16.SET_SLOT);
        clearPacket.write(Type.UNSIGNED_BYTE, (short) -1);
        clearPacket.write(Type.SHORT, (short) -1);
        clearPacket.write(Type.FLAT_VAR_INT_ITEM, null);
        clearPacket.send(Protocol1_16To1_15_2.class);
    };
    protocol.registerClientbound(ClientboundPackets1_15.OPEN_WINDOW, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Window Id
            map(Type.VAR_INT);
            // Window Type
            map(Type.VAR_INT);
            // Window Title
            map(Type.COMPONENT);
            handler(cursorRemapper);
            handler(wrapper -> {
                InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class);
                int windowId = wrapper.get(Type.VAR_INT, 0);
                int windowType = wrapper.get(Type.VAR_INT, 1);
                if (windowType >= 20) {
                    // smithing added with id 20
                    wrapper.set(Type.VAR_INT, 1, ++windowType);
                }
                inventoryTracker.setInventory((short) windowId);
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_15.CLOSE_WINDOW, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(cursorRemapper);
            handler(wrapper -> {
                InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class);
                inventoryTracker.setInventory((short) -1);
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_15.WINDOW_PROPERTY, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Window Id
            map(Type.UNSIGNED_BYTE);
            // Property
            map(Type.SHORT);
            // Value
            map(Type.SHORT);
            handler(wrapper -> {
                short property = wrapper.get(Type.SHORT, 0);
                if (property >= 4 && property <= 6) {
                    // Enchantment id
                    short enchantmentId = wrapper.get(Type.SHORT, 1);
                    if (enchantmentId >= 11) {
                        // soul_speed added with id 11
                        wrapper.set(Type.SHORT, 1, ++enchantmentId);
                    }
                }
            });
        }
    });
    registerSetCooldown(ClientboundPackets1_15.COOLDOWN);
    registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
    registerTradeList(ClientboundPackets1_15.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
    registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
    registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
    protocol.registerClientbound(ClientboundPackets1_15.ENTITY_EQUIPMENT, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Entity ID
            map(Type.VAR_INT);
            handler(wrapper -> {
                int slot = wrapper.read(Type.VAR_INT);
                wrapper.write(Type.BYTE, (byte) slot);
                handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
            });
        }
    });
    new RecipeRewriter1_14(protocol).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
    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.CLOSE_WINDOW, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> {
                InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class);
                inventoryTracker.setInventory((short) -1);
            });
        }
    });
    protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
        }
    });
    registerSpawnParticle(ClientboundPackets1_15.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
}
Also used : PacketHandler(com.viaversion.viaversion.api.protocol.remapper.PacketHandler) ItemRewriter(com.viaversion.viaversion.rewriter.ItemRewriter) ListTag(com.github.steveice10.opennbt.tag.builtin.ListTag) RecipeRewriter1_14(com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14) IntArrayTag(com.github.steveice10.opennbt.tag.builtin.IntArrayTag) NumberTag(com.github.steveice10.opennbt.tag.builtin.NumberTag) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) UUID(java.util.UUID) Item(com.viaversion.viaversion.api.minecraft.item.Item) UUIDIntArrayType(com.viaversion.viaversion.api.type.types.UUIDIntArrayType) Protocol1_16To1_15_2(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2) StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) ClientboundPackets1_16(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16) Type(com.viaversion.viaversion.api.type.Type) ServerboundPackets1_16(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16) InventoryTracker1_16(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16) Tag(com.github.steveice10.opennbt.tag.builtin.Tag) LongTag(com.github.steveice10.opennbt.tag.builtin.LongTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) ClientboundPackets1_15(com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15) RecipeRewriter1_14(com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14) Protocol1_16To1_15_2(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2) PacketHandler(com.viaversion.viaversion.api.protocol.remapper.PacketHandler) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) InventoryTracker1_16(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16)

Example 39 with Item

use of com.viaversion.viaversion.api.minecraft.item.Item in project ViaVersion by ViaVersion.

the class EntityTracker1_9 method handleMetadata.

public void handleMetadata(int entityId, List<Metadata> metadataList) {
    com.viaversion.viaversion.api.minecraft.entities.EntityType type = entityType(entityId);
    if (type == null) {
        return;
    }
    for (Metadata metadata : new ArrayList<>(metadataList)) {
        // Fix: wither (crash fix)
        if (type == EntityType.WITHER) {
            if (metadata.id() == 10) {
                metadataList.remove(metadata);
            // metadataList.add(new Metadata(10, NewType.Byte.getTypeID(), Type.BYTE, 0));
            }
        }
        // Fix: enderdragon (crash fix)
        if (type == EntityType.ENDER_DRAGON) {
            if (metadata.id() == 11) {
                metadataList.remove(metadata);
            // metadataList.add(new Metadata(11, NewType.Byte.getTypeID(), Type.VAR_INT, 0));
            }
        }
        if (type == EntityType.SKELETON) {
            if ((getMetaByIndex(metadataList, 12)) == null) {
                metadataList.add(new Metadata(12, MetaType1_9.Boolean, true));
            }
        }
        // ECHOPET Patch
        if (type == EntityType.HORSE) {
            // Wrong metadata value from EchoPet, patch since it's discontinued. (https://github.com/DSH105/EchoPet/blob/06947a8b08ce40be9a518c2982af494b3b99d140/modules/API/src/main/java/com/dsh105/echopet/compat/api/entity/HorseArmour.java#L22)
            if (metadata.id() == 16 && (int) metadata.getValue() == Integer.MIN_VALUE)
                metadata.setValue(0);
        }
        if (type == EntityType.PLAYER) {
            if (metadata.id() == 0) {
                // Byte
                byte data = (byte) metadata.getValue();
                if (entityId != getProvidedEntityId() && Via.getConfig().isShieldBlocking()) {
                    if ((data & 0x10) == 0x10) {
                        if (validBlocking.contains(entityId)) {
                            Item shield = new DataItem(442, (byte) 1, (short) 0, null);
                            setSecondHand(entityId, shield);
                        } else {
                            setSecondHand(entityId, null);
                        }
                    } else {
                        setSecondHand(entityId, null);
                    }
                }
            }
            if (metadata.id() == 12 && Via.getConfig().isLeftHandedHandling()) {
                // Player model
                metadataList.add(new Metadata(// Main hand
                13, MetaType1_9.Byte, (byte) (((((byte) metadata.getValue()) & 0x80) != 0) ? 0 : 1)));
            }
        }
        if (type == EntityType.ARMOR_STAND && Via.getConfig().isHologramPatch()) {
            if (metadata.id() == 0 && getMetaByIndex(metadataList, 10) != null) {
                // Only happens if the armorstand is small
                Metadata meta = getMetaByIndex(metadataList, 10);
                byte data = (byte) metadata.getValue();
                // Check invisible | Check small | Check if custom name is empty | Check if custom name visible is true
                Metadata displayName;
                Metadata displayNameVisible;
                if ((data & 0x20) == 0x20 && ((byte) meta.getValue() & 0x01) == 0x01 && (displayName = getMetaByIndex(metadataList, 2)) != null && !((String) displayName.getValue()).isEmpty() && (displayNameVisible = getMetaByIndex(metadataList, 3)) != null && (boolean) displayNameVisible.getValue()) {
                    if (!knownHolograms.contains(entityId)) {
                        knownHolograms.add(entityId);
                        try {
                            // Send movement
                            PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.ENTITY_POSITION, null, user());
                            wrapper.write(Type.VAR_INT, entityId);
                            wrapper.write(Type.SHORT, (short) 0);
                            wrapper.write(Type.SHORT, (short) (128D * (Via.getConfig().getHologramYOffset() * 32D)));
                            wrapper.write(Type.SHORT, (short) 0);
                            wrapper.write(Type.BOOLEAN, true);
                            wrapper.scheduleSend(Protocol1_9To1_8.class);
                        } catch (Exception ignored) {
                        }
                    }
                }
            }
        }
        // Boss bar
        if (Via.getConfig().isBossbarPatch()) {
            if (type == EntityType.ENDER_DRAGON || type == EntityType.WITHER) {
                if (metadata.id() == 2) {
                    BossBar bar = bossBarMap.get(entityId);
                    String title = (String) metadata.getValue();
                    title = title.isEmpty() ? (type == EntityType.ENDER_DRAGON ? DRAGON_TRANSLATABLE : WITHER_TRANSLATABLE) : title;
                    if (bar == null) {
                        bar = Via.getAPI().legacyAPI().createLegacyBossBar(title, BossColor.PINK, BossStyle.SOLID);
                        bossBarMap.put(entityId, bar);
                        bar.addConnection(user());
                        bar.show();
                        // Send to provider
                        Via.getManager().getProviders().get(BossBarProvider.class).handleAdd(user(), bar.getId());
                    } else {
                        bar.setTitle(title);
                    }
                } else if (metadata.id() == 6 && !Via.getConfig().isBossbarAntiflicker()) {
                    // If anti flicker is enabled, don't update health
                    BossBar bar = bossBarMap.get(entityId);
                    // Make health range between 0 and 1
                    float maxHealth = type == EntityType.ENDER_DRAGON ? 200.0f : 300.0f;
                    float health = Math.max(0.0f, Math.min(((float) metadata.getValue()) / maxHealth, 1.0f));
                    if (bar == null) {
                        String title = type == EntityType.ENDER_DRAGON ? DRAGON_TRANSLATABLE : WITHER_TRANSLATABLE;
                        bar = Via.getAPI().legacyAPI().createLegacyBossBar(title, health, BossColor.PINK, BossStyle.SOLID);
                        bossBarMap.put(entityId, bar);
                        bar.addConnection(user());
                        bar.show();
                        // Send to provider
                        Via.getManager().getProviders().get(BossBarProvider.class).handleAdd(user(), bar.getId());
                    } else {
                        bar.setHealth(health);
                    }
                }
            }
        }
    }
}
Also used : DataItem(com.viaversion.viaversion.api.minecraft.item.DataItem) Metadata(com.viaversion.viaversion.api.minecraft.metadata.Metadata) BossBar(com.viaversion.viaversion.api.legacy.bossbar.BossBar) Item(com.viaversion.viaversion.api.minecraft.item.Item) DataItem(com.viaversion.viaversion.api.minecraft.item.DataItem) BossBarProvider(com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.BossBarProvider) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper)

Example 40 with Item

use of com.viaversion.viaversion.api.minecraft.item.Item in project ViaVersion by ViaVersion.

the class Protocol1_13_1To1_13 method registerPackets.

@Override
protected void registerPackets() {
    entityRewriter.register();
    itemRewriter.register();
    EntityPackets.register(this);
    WorldPackets.register(this);
    registerServerbound(ServerboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {

        @Override
        public void registerMap() {
            map(Type.VAR_INT);
            map(Type.STRING, new ValueTransformer<String, String>(Type.STRING) {

                @Override
                public String transform(PacketWrapper wrapper, String inputValue) {
                    // 1.13 starts sending slash at start, so we remove it for compatibility
                    return inputValue.startsWith("/") ? inputValue.substring(1) : inputValue;
                }
            });
        }
    });
    registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {

        @Override
        public void registerMap() {
            map(Type.FLAT_ITEM);
            map(Type.BOOLEAN);
            handler(wrapper -> {
                Item item = wrapper.get(Type.FLAT_ITEM, 0);
                itemRewriter.handleItemToServer(item);
            });
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int hand = wrapper.read(Type.VAR_INT);
                    if (hand == 1) {
                        wrapper.cancel();
                    }
                }
            });
        }
    });
    registerClientbound(ClientboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Transaction id
            map(Type.VAR_INT);
            // Start
            map(Type.VAR_INT);
            // Length
            map(Type.VAR_INT);
            // Count
            map(Type.VAR_INT);
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int start = wrapper.get(Type.VAR_INT, 1);
                    // Offset by +1 to take into account / at beginning
                    wrapper.set(Type.VAR_INT, 1, start + 1);
                    // Passthrough suggestions
                    int count = wrapper.get(Type.VAR_INT, 3);
                    for (int i = 0; i < count; i++) {
                        wrapper.passthrough(Type.STRING);
                        boolean hasTooltip = wrapper.passthrough(Type.BOOLEAN);
                        if (hasTooltip) {
                            // JSON Tooltip
                            wrapper.passthrough(Type.STRING);
                        }
                    }
                }
            });
        }
    });
    registerClientbound(ClientboundPackets1_13.BOSSBAR, new PacketRemapper() {

        @Override
        public void registerMap() {
            map(Type.UUID);
            map(Type.VAR_INT);
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int action = wrapper.get(Type.VAR_INT, 0);
                    if (action == 0) {
                        wrapper.passthrough(Type.COMPONENT);
                        wrapper.passthrough(Type.FLOAT);
                        wrapper.passthrough(Type.VAR_INT);
                        wrapper.passthrough(Type.VAR_INT);
                        short flags = wrapper.read(Type.BYTE);
                        if ((flags & 0x02) != 0)
                            flags |= 0x04;
                        wrapper.write(Type.UNSIGNED_BYTE, flags);
                    }
                }
            });
        }
    });
    new TagRewriter(this).register(ClientboundPackets1_13.TAGS, RegistryType.ITEM);
    new StatisticsRewriter(this).register(ClientboundPackets1_13.STATISTICS);
}
Also used : ValueTransformer(com.viaversion.viaversion.api.protocol.remapper.ValueTransformer) PacketHandler(com.viaversion.viaversion.api.protocol.remapper.PacketHandler) InventoryPackets(com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets.InventoryPackets) MappingData(com.viaversion.viaversion.api.data.MappingData) EntityPackets(com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets.EntityPackets) ClientWorld(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) Entity1_13Types(com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types) Item(com.viaversion.viaversion.api.minecraft.item.Item) AbstractProtocol(com.viaversion.viaversion.api.protocol.AbstractProtocol) MappingDataBase(com.viaversion.viaversion.api.data.MappingDataBase) RegistryType(com.viaversion.viaversion.api.minecraft.RegistryType) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) ClientboundPackets1_13(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13) Type(com.viaversion.viaversion.api.type.Type) MetadataRewriter1_13_1To1_13(com.viaversion.viaversion.protocols.protocol1_13_1to1_13.metadata.MetadataRewriter1_13_1To1_13) ServerboundPackets1_13(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13) TagRewriter(com.viaversion.viaversion.rewriter.TagRewriter) StatisticsRewriter(com.viaversion.viaversion.rewriter.StatisticsRewriter) EntityTrackerBase(com.viaversion.viaversion.data.entity.EntityTrackerBase) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) ValueTransformer(com.viaversion.viaversion.api.protocol.remapper.ValueTransformer) ItemRewriter(com.viaversion.viaversion.api.rewriter.ItemRewriter) EntityRewriter(com.viaversion.viaversion.api.rewriter.EntityRewriter) WorldPackets(com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets.WorldPackets) TagRewriter(com.viaversion.viaversion.rewriter.TagRewriter) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) Item(com.viaversion.viaversion.api.minecraft.item.Item) StatisticsRewriter(com.viaversion.viaversion.rewriter.StatisticsRewriter) PacketHandler(com.viaversion.viaversion.api.protocol.remapper.PacketHandler) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper)

Aggregations

Item (com.viaversion.viaversion.api.minecraft.item.Item)43 PacketWrapper (com.viaversion.viaversion.api.protocol.packet.PacketWrapper)28 PacketRemapper (com.viaversion.viaversion.api.protocol.remapper.PacketRemapper)27 PacketHandler (com.viaversion.viaversion.api.protocol.remapper.PacketHandler)23 Type (com.viaversion.viaversion.api.type.Type)15 DataItem (com.viaversion.viaversion.api.minecraft.item.DataItem)13 ClientWorld (com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld)9 Metadata (com.viaversion.viaversion.api.minecraft.metadata.Metadata)8 ArrayList (java.util.ArrayList)8 CompoundTag (com.github.steveice10.opennbt.tag.builtin.CompoundTag)6 Position (com.viaversion.viaversion.api.minecraft.Position)6 Chunk (com.viaversion.viaversion.api.minecraft.chunks.Chunk)6 ClientboundPackets1_13 (com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13)6 List (java.util.List)6 StringTag (com.github.steveice10.opennbt.tag.builtin.StringTag)5 Via (com.viaversion.viaversion.api.Via)5 UserConnection (com.viaversion.viaversion.api.connection.UserConnection)5 UUID (java.util.UUID)5 ListTag (com.github.steveice10.opennbt.tag.builtin.ListTag)4 ViaBackwards (com.viaversion.viabackwards.ViaBackwards)4