Search in sources :

Example 91 with PacketWrapper

use of com.viaversion.viaversion.api.protocol.packet.PacketWrapper 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 92 with PacketWrapper

use of com.viaversion.viaversion.api.protocol.packet.PacketWrapper in project ViaVersion by ViaVersion.

the class Protocol1_9_1_2To1_9_3_4 method registerPackets.

@Override
protected void registerPackets() {
    registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() {

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

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 9) {
                        Position position = wrapper.get(Type.POSITION, 0);
                        CompoundTag tag = wrapper.get(Type.NBT, 0);
                        // Clear the packet
                        wrapper.clearPacket();
                        // Update sign packet
                        wrapper.setId(ClientboundPackets1_9.UPDATE_SIGN.ordinal());
                        // Position
                        wrapper.write(Type.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
                            // Sign line
                            wrapper.write(Type.STRING, (String) tag.get("Text" + i).getValue());
                        }
                    }
                }
            });
        }
    });
    registerClientbound(ClientboundPackets1_9_3.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);
                    Chunk1_9_3_4Type newType = new Chunk1_9_3_4Type(clientWorld);
                    // Get the old type to not write Block Entities
                    Chunk1_9_1_2Type oldType = new Chunk1_9_1_2Type(clientWorld);
                    Chunk chunk = wrapper.read(newType);
                    wrapper.write(oldType, chunk);
                    BlockEntity.handle(chunk.getBlockEntities(), wrapper.user());
                }
            });
        }
    });
    registerClientbound(ClientboundPackets1_9_3.JOIN_GAME, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Entity ID
            map(Type.INT);
            // 1 - Gamemode
            map(Type.UNSIGNED_BYTE);
            // 2 - Dimension
            map(Type.INT);
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
                    int dimensionId = wrapper.get(Type.INT, 1);
                    clientChunks.setEnvironment(dimensionId);
                }
            });
        }
    });
    registerClientbound(ClientboundPackets1_9_3.RESPAWN, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Dimension ID
            map(Type.INT);
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
                    int dimensionId = wrapper.get(Type.INT, 0);
                    clientWorld.setEnvironment(dimensionId);
                }
            });
        }
    });
}
Also used : PacketHandler(com.viaversion.viaversion.api.protocol.remapper.PacketHandler) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) Position(com.viaversion.viaversion.api.minecraft.Position) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) Chunk1_9_1_2Type(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type) ClientWorld(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld) Chunk(com.viaversion.viaversion.api.minecraft.chunks.Chunk) Chunk1_9_3_4Type(com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag)

Example 93 with PacketWrapper

use of com.viaversion.viaversion.api.protocol.packet.PacketWrapper in project ViaVersion by ViaVersion.

the class Protocol1_9_3To1_9_1_2 method registerPackets.

@Override
protected void registerPackets() {
    // Sign update packet
    registerClientbound(ClientboundPackets1_9.UPDATE_SIGN, null, new PacketRemapper() {

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

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    // read data
                    Position position = wrapper.read(Type.POSITION);
                    JsonElement[] lines = new JsonElement[4];
                    for (int i = 0; i < 4; i++) {
                        lines[i] = wrapper.read(Type.COMPONENT);
                    }
                    wrapper.clearInputBuffer();
                    // write data
                    // Update block entity
                    wrapper.setId(0x09);
                    // Block location
                    wrapper.write(Type.POSITION, position);
                    // Action type (9 update sign)
                    wrapper.write(Type.UNSIGNED_BYTE, (short) 9);
                    // Create nbt
                    CompoundTag tag = new CompoundTag();
                    tag.put("id", new StringTag("Sign"));
                    tag.put("x", new IntTag(position.x()));
                    tag.put("y", new IntTag(position.y()));
                    tag.put("z", new IntTag(position.z()));
                    for (int i = 0; i < lines.length; i++) {
                        tag.put("Text" + (i + 1), new StringTag(lines[i].toString()));
                    }
                    wrapper.write(Type.NBT, tag);
                }
            });
        }
    });
    registerClientbound(ClientboundPackets1_9.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);
                    Chunk chunk = wrapper.read(new Chunk1_9_1_2Type(clientWorld));
                    wrapper.write(new Chunk1_9_3_4Type(clientWorld), chunk);
                    List<CompoundTag> tags = chunk.getBlockEntities();
                    for (int i = 0; i < chunk.getSections().length; i++) {
                        ChunkSection section = chunk.getSections()[i];
                        if (section == null)
                            continue;
                        for (int y = 0; y < 16; y++) {
                            for (int z = 0; z < 16; z++) {
                                for (int x = 0; x < 16; x++) {
                                    int block = section.getBlockWithoutData(x, y, z);
                                    if (FakeTileEntity.isTileEntity(block)) {
                                        tags.add(FakeTileEntity.createTileEntity(x + (chunk.getX() << 4), y + (i << 4), z + (chunk.getZ() << 4), block));
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
    });
    registerClientbound(ClientboundPackets1_9.JOIN_GAME, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Entity ID
            map(Type.INT);
            // 1 - Gamemode
            map(Type.UNSIGNED_BYTE);
            // 2 - Dimension
            map(Type.INT);
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
                    int dimensionId = wrapper.get(Type.INT, 1);
                    clientWorld.setEnvironment(dimensionId);
                }
            });
        }
    });
    registerClientbound(ClientboundPackets1_9.RESPAWN, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Dimension ID
            map(Type.INT);
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
                    int dimensionId = wrapper.get(Type.INT, 0);
                    clientWorld.setEnvironment(dimensionId);
                }
            });
        }
    });
    // Sound effect
    registerClientbound(ClientboundPackets1_9.SOUND, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Sound name
            map(Type.VAR_INT);
            // 1 - Sound Category
            map(Type.VAR_INT);
            // 2 - x
            map(Type.INT);
            // 3 - y
            map(Type.INT);
            // 4 - z
            map(Type.INT);
            // 5 - Volume
            map(Type.FLOAT);
            // 6 - Pitch
            map(ADJUST_PITCH);
        }
    });
}
Also used : StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) Position(com.viaversion.viaversion.api.minecraft.Position) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) Chunk(com.viaversion.viaversion.api.minecraft.chunks.Chunk) Chunk1_9_3_4Type(com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type) PacketHandler(com.viaversion.viaversion.api.protocol.remapper.PacketHandler) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) JsonElement(com.google.gson.JsonElement) Chunk1_9_1_2Type(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type) ClientWorld(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld) ChunkSection(com.viaversion.viaversion.api.minecraft.chunks.ChunkSection) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) IntTag(com.github.steveice10.opennbt.tag.builtin.IntTag)

Example 94 with PacketWrapper

use of com.viaversion.viaversion.api.protocol.packet.PacketWrapper in project ViaVersion by ViaVersion.

the class EntityTracker1_9 method sendTeamPacket.

public void sendTeamPacket(boolean add, boolean now) {
    PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.TEAMS, null, user());
    // Use viaversion as name
    wrapper.write(Type.STRING, "viaversion");
    if (add) {
        // add
        if (!teamExists) {
            // make team
            wrapper.write(Type.BYTE, (byte) 0);
            wrapper.write(Type.STRING, "viaversion");
            // prefix
            wrapper.write(Type.STRING, "§f");
            // suffix
            wrapper.write(Type.STRING, "");
            // friendly fire
            wrapper.write(Type.BYTE, (byte) 0);
            // nametags
            wrapper.write(Type.STRING, "");
            // collision rule :)
            wrapper.write(Type.STRING, "never");
            // color
            wrapper.write(Type.BYTE, (byte) 15);
        } else {
            wrapper.write(Type.BYTE, (byte) 3);
        }
        wrapper.write(Type.STRING_ARRAY, new String[] { user().getProtocolInfo().getUsername() });
    } else {
        // remove team
        wrapper.write(Type.BYTE, (byte) 1);
    }
    teamExists = add;
    try {
        if (now) {
            wrapper.send(Protocol1_9To1_8.class);
        } else {
            wrapper.scheduleSend(Protocol1_9To1_8.class);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper)

Example 95 with PacketWrapper

use of com.viaversion.viaversion.api.protocol.packet.PacketWrapper 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)

Aggregations

PacketWrapper (com.viaversion.viaversion.api.protocol.packet.PacketWrapper)107 PacketRemapper (com.viaversion.viaversion.api.protocol.remapper.PacketRemapper)76 PacketHandler (com.viaversion.viaversion.api.protocol.remapper.PacketHandler)63 Type (com.viaversion.viaversion.api.type.Type)38 Item (com.viaversion.viaversion.api.minecraft.item.Item)32 Chunk (com.viaversion.viaversion.api.minecraft.chunks.Chunk)22 Metadata (com.viaversion.viaversion.api.minecraft.metadata.Metadata)22 ClientWorld (com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld)22 ChunkSection (com.viaversion.viaversion.api.minecraft.chunks.ChunkSection)18 ArrayList (java.util.ArrayList)17 UserConnection (com.viaversion.viaversion.api.connection.UserConnection)16 Position (com.viaversion.viaversion.api.minecraft.Position)16 List (java.util.List)14 ClientboundPackets1_13 (com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13)13 CompoundTag (com.github.steveice10.opennbt.tag.builtin.CompoundTag)11 EntityType (com.viaversion.viaversion.api.minecraft.entities.EntityType)11 ViaBackwards (com.viaversion.viabackwards.ViaBackwards)10 Via (com.viaversion.viaversion.api.Via)9 BlockChangeRecord (com.viaversion.viaversion.api.minecraft.BlockChangeRecord)9 ClientboundPackets1_14 (com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14)9