Search in sources :

Example 1 with EntityTracker

use of com.viaversion.viaversion.api.data.entity.EntityTracker in project ViaBackwards by ViaVersion.

the class BlockItemPackets1_11 method getChestedHorse.

private Optional<ChestedHorseStorage> getChestedHorse(UserConnection user) {
    WindowTracker tracker = user.get(WindowTracker.class);
    if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
        EntityTracker entTracker = user.getEntityTracker(Protocol1_10To1_11.class);
        StoredEntityData entityData = entTracker.entityData(tracker.getEntityId());
        if (entityData != null)
            return Optional.of(entityData.get(ChestedHorseStorage.class));
    }
    return Optional.empty();
}
Also used : WindowTracker(com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker) EntityTracker(com.viaversion.viaversion.api.data.entity.EntityTracker) StoredEntityData(com.viaversion.viaversion.api.data.entity.StoredEntityData)

Example 2 with EntityTracker

use of com.viaversion.viaversion.api.data.entity.EntityTracker in project ViaBackwards by ViaVersion.

the class BlockItemPackets1_11 method isLlama.

private boolean isLlama(UserConnection user) {
    WindowTracker tracker = user.get(WindowTracker.class);
    if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
        EntityTracker entTracker = user.getEntityTracker(Protocol1_10To1_11.class);
        StoredEntityData entityData = entTracker.entityData(tracker.getEntityId());
        return entityData != null && entityData.type().is(Entity1_11Types.EntityType.LIAMA);
    }
    return false;
}
Also used : WindowTracker(com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker) EntityTracker(com.viaversion.viaversion.api.data.entity.EntityTracker) StoredEntityData(com.viaversion.viaversion.api.data.entity.StoredEntityData)

Example 3 with EntityTracker

use of com.viaversion.viaversion.api.data.entity.EntityTracker in project ViaBackwards by ViaVersion.

the class EntityPackets1_14 method registerPackets.

@Override
protected void registerPackets() {
    positionHandler = new EntityPositionHandler(this, EntityPositionStorage1_14.class, EntityPositionStorage1_14::new);
    protocol.registerClientbound(ClientboundPackets1_14.ENTITY_STATUS, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> {
                int entityId = wrapper.passthrough(Type.INT);
                byte status = wrapper.passthrough(Type.BYTE);
                // Check for death status
                if (status != 3)
                    return;
                EntityTracker tracker = tracker(wrapper.user());
                EntityType entityType = tracker.entityType(entityId);
                if (entityType != Entity1_14Types.PLAYER)
                    return;
                // Remove equipment, else the client will see ghost items
                for (int i = 0; i <= 5; i++) {
                    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.send(Protocol1_13_2To1_14.class);
                }
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_14.ENTITY_TELEPORT, new PacketRemapper() {

        @Override
        public void registerMap() {
            map(Type.VAR_INT);
            map(Type.DOUBLE);
            map(Type.DOUBLE);
            map(Type.DOUBLE);
            handler(wrapper -> positionHandler.cacheEntityPosition(wrapper, false, false));
        }
    });
    PacketRemapper relativeMoveHandler = new PacketRemapper() {

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

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    double x = wrapper.get(Type.SHORT, 0) / EntityPositionHandler.RELATIVE_MOVE_FACTOR;
                    double y = wrapper.get(Type.SHORT, 1) / EntityPositionHandler.RELATIVE_MOVE_FACTOR;
                    double z = wrapper.get(Type.SHORT, 2) / EntityPositionHandler.RELATIVE_MOVE_FACTOR;
                    positionHandler.cacheEntityPosition(wrapper, x, y, z, false, true);
                }
            });
        }
    };
    protocol.registerClientbound(ClientboundPackets1_14.ENTITY_POSITION, relativeMoveHandler);
    protocol.registerClientbound(ClientboundPackets1_14.ENTITY_POSITION_AND_ROTATION, relativeMoveHandler);
    protocol.registerClientbound(ClientboundPackets1_14.SPAWN_ENTITY, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Entity id
            map(Type.VAR_INT);
            // 1 - UUID
            map(Type.UUID);
            // 2 - Type
            map(Type.VAR_INT, Type.BYTE);
            // 3 - X
            map(Type.DOUBLE);
            // 4 - Y
            map(Type.DOUBLE);
            // 5 - Z
            map(Type.DOUBLE);
            // 6 - Pitch
            map(Type.BYTE);
            // 7 - Yaw
            map(Type.BYTE);
            // 8 - Data
            map(Type.INT);
            // 9 - Velocity X
            map(Type.SHORT);
            // 10 - Velocity Y
            map(Type.SHORT);
            // 11 - Velocity Z
            map(Type.SHORT);
            handler(getObjectTrackerHandler());
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int id = wrapper.get(Type.BYTE, 0);
                    int mappedId = newEntityId(id);
                    Entity1_13Types.EntityType entityType = Entity1_13Types.getTypeFromId(mappedId, false);
                    Entity1_13Types.ObjectType objectType;
                    if (entityType.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT)) {
                        objectType = Entity1_13Types.ObjectType.MINECART;
                        int data = 0;
                        switch(entityType) {
                            case CHEST_MINECART:
                                data = 1;
                                break;
                            case FURNACE_MINECART:
                                data = 2;
                                break;
                            case TNT_MINECART:
                                data = 3;
                                break;
                            case SPAWNER_MINECART:
                                data = 4;
                                break;
                            case HOPPER_MINECART:
                                data = 5;
                                break;
                            case COMMAND_BLOCK_MINECART:
                                data = 6;
                                break;
                        }
                        if (data != 0)
                            wrapper.set(Type.INT, 0, data);
                    } else {
                        objectType = Entity1_13Types.ObjectType.fromEntityType(entityType).orElse(null);
                    }
                    if (objectType == null)
                        return;
                    wrapper.set(Type.BYTE, 0, (byte) objectType.getId());
                    int data = wrapper.get(Type.INT, 0);
                    if (objectType == Entity1_13Types.ObjectType.FALLING_BLOCK) {
                        int blockState = wrapper.get(Type.INT, 0);
                        int combined = protocol.getMappingData().getNewBlockStateId(blockState);
                        wrapper.set(Type.INT, 0, combined);
                    } else if (entityType.isOrHasParent(Entity1_13Types.EntityType.ABSTRACT_ARROW)) {
                        wrapper.set(Type.INT, 0, data + 1);
                    }
                }
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Entity ID
            map(Type.VAR_INT);
            // 1 - Entity UUID
            map(Type.UUID);
            // 2 - Entity Type
            map(Type.VAR_INT);
            // 3 - X
            map(Type.DOUBLE);
            // 4 - Y
            map(Type.DOUBLE);
            // 5 - Z
            map(Type.DOUBLE);
            // 6 - Yaw
            map(Type.BYTE);
            // 7 - Pitch
            map(Type.BYTE);
            // 8 - Head Pitch
            map(Type.BYTE);
            // 9 - Velocity X
            map(Type.SHORT);
            // 10 - Velocity Y
            map(Type.SHORT);
            // 11 - Velocity Z
            map(Type.SHORT);
            // 12 - Metadata
            map(Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST);
            handler(new PacketHandler() {

                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int type = wrapper.get(Type.VAR_INT, 1);
                    EntityType entityType = Entity1_14Types.getTypeFromId(type);
                    addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType);
                    int oldId = newEntityId(type);
                    if (oldId == -1) {
                        EntityData entityData = entityDataForType(entityType);
                        if (entityData == null) {
                            ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13.2 entity type for 1.14 entity type " + type + "/" + entityType);
                            wrapper.cancel();
                        } else {
                            wrapper.set(Type.VAR_INT, 1, entityData.replacementId());
                        }
                    } else {
                        wrapper.set(Type.VAR_INT, 1, oldId);
                    }
                }
            });
            // Handle entity type & metadata
            handler(getMobSpawnRewriter(Types1_13_2.METADATA_LIST));
        }
    });
    protocol.registerClientbound(ClientboundPackets1_14.SPAWN_EXPERIENCE_ORB, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Entity id
            map(Type.VAR_INT);
            // Needs to be mapped for the position cache
            map(Type.DOUBLE);
            map(Type.DOUBLE);
            map(Type.DOUBLE);
            handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EXPERIENCE_ORB));
        }
    });
    protocol.registerClientbound(ClientboundPackets1_14.SPAWN_GLOBAL_ENTITY, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Entity id
            map(Type.VAR_INT);
            map(Type.BYTE);
            // Needs to be mapped for the position cache
            map(Type.DOUBLE);
            map(Type.DOUBLE);
            map(Type.DOUBLE);
            handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.LIGHTNING_BOLT));
        }
    });
    protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PAINTING, new PacketRemapper() {

        @Override
        public void registerMap() {
            map(Type.VAR_INT);
            map(Type.UUID);
            map(Type.VAR_INT);
            map(Type.POSITION1_14, Type.POSITION);
            map(Type.BYTE);
            // Track entity
            handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.PAINTING));
        }
    });
    protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PLAYER, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Entity ID
            map(Type.VAR_INT);
            // 1 - Player UUID
            map(Type.UUID);
            // 2 - X
            map(Type.DOUBLE);
            // 3 - Y
            map(Type.DOUBLE);
            // 4 - Z
            map(Type.DOUBLE);
            // 5 - Yaw
            map(Type.BYTE);
            // 6 - Pitch
            map(Type.BYTE);
            // 7 - Metadata
            map(Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST);
            handler(getTrackerAndMetaHandler(Types1_13_2.METADATA_LIST, Entity1_14Types.PLAYER));
            handler(wrapper -> positionHandler.cacheEntityPosition(wrapper, true, false));
        }
    });
    registerRemoveEntities(ClientboundPackets1_14.DESTROY_ENTITIES);
    registerMetadataRewriter(ClientboundPackets1_14.ENTITY_METADATA, Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST);
    protocol.registerClientbound(ClientboundPackets1_14.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(getTrackerHandler(Entity1_14Types.PLAYER, Type.INT));
            handler(getDimensionHandler(1));
            handler(wrapper -> {
                short difficulty = wrapper.user().get(DifficultyStorage.class).getDifficulty();
                wrapper.write(Type.UNSIGNED_BYTE, difficulty);
                // Max Players
                wrapper.passthrough(Type.UNSIGNED_BYTE);
                // Level Type
                wrapper.passthrough(Type.STRING);
                // Read View Distance
                wrapper.read(Type.VAR_INT);
            // TODO Track client position
            // Manually add position storage
            /*int entitiyId = wrapper.get(Type.INT, 0);
                    StoredEntityData storedEntity = protocol.getEntityRewriter().tracker(wrapper.user()).entityData(entitiyId);
                    storedEntity.put(new EntityPositionStorage1_14());*/
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_14.RESPAWN, new PacketRemapper() {

        @Override
        public void registerMap() {
            // 0 - Dimension ID
            map(Type.INT);
            handler(wrapper -> {
                ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
                int dimensionId = wrapper.get(Type.INT, 0);
                clientWorld.setEnvironment(dimensionId);
                short difficulty = wrapper.user().get(DifficultyStorage.class).getDifficulty();
                wrapper.write(Type.UNSIGNED_BYTE, difficulty);
                wrapper.user().get(ChunkLightStorage.class).clear();
            });
        }
    });
}
Also used : EntityPositionHandler(com.viaversion.viabackwards.api.entities.storage.EntityPositionHandler) PacketHandler(com.viaversion.viaversion.api.protocol.remapper.PacketHandler) MetaType(com.viaversion.viaversion.api.minecraft.metadata.MetaType) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) Entity1_13Types(com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types) EntityPositionStorage1_14(com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositionStorage1_14) Item(com.viaversion.viaversion.api.minecraft.item.Item) Metadata(com.viaversion.viaversion.api.minecraft.metadata.Metadata) Types1_14(com.viaversion.viaversion.api.type.types.version.Types1_14) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) Type(com.viaversion.viaversion.api.type.Type) ChunkLightStorage(com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage) Protocol1_13_2To1_14(com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14) EntityData(com.viaversion.viabackwards.api.entities.storage.EntityData) Particle(com.viaversion.viaversion.api.type.types.Particle) LegacyEntityRewriter(com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter) Position(com.viaversion.viaversion.api.minecraft.Position) Types1_13_2(com.viaversion.viaversion.api.type.types.version.Types1_13_2) ClientWorld(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld) EntityTracker(com.viaversion.viaversion.api.data.entity.EntityTracker) EntityType(com.viaversion.viaversion.api.minecraft.entities.EntityType) VillagerData(com.viaversion.viaversion.api.minecraft.VillagerData) EntityPositionHandler(com.viaversion.viabackwards.api.entities.storage.EntityPositionHandler) ClientboundPackets1_13(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13) DifficultyStorage(com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage) MetaHandler(com.viaversion.viaversion.rewriter.meta.MetaHandler) ViaBackwards(com.viaversion.viabackwards.ViaBackwards) ClientboundPackets1_14(com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14) Entity1_14Types(com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types) EntityPositionStorage1_14(com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositionStorage1_14) EntityTracker(com.viaversion.viaversion.api.data.entity.EntityTracker) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) EntityData(com.viaversion.viabackwards.api.entities.storage.EntityData) EntityType(com.viaversion.viaversion.api.minecraft.entities.EntityType) PacketHandler(com.viaversion.viaversion.api.protocol.remapper.PacketHandler) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) Entity1_13Types(com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types) ClientWorld(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld) Protocol1_13_2To1_14(com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14)

Example 4 with EntityTracker

use of com.viaversion.viaversion.api.data.entity.EntityTracker in project ViaBackwards by ViaVersion.

the class BlockItemPackets1_17 method registerPackets.

@Override
protected void registerPackets() {
    BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
    new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_17.DECLARE_RECIPES);
    registerSetCooldown(ClientboundPackets1_17.COOLDOWN);
    registerWindowItems(ClientboundPackets1_17.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
    registerSetSlot(ClientboundPackets1_17.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
    registerEntityEquipmentArray(ClientboundPackets1_17.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
    registerTradeList(ClientboundPackets1_17.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
    registerAdvancements(ClientboundPackets1_17.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
    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, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
        }
    });
    // TODO This will cause desync issues for players under certain circumstances, but mostly works:tm:
    protocol.registerServerbound(ServerboundPackets1_16_2.CLICK_WINDOW, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Window Id
            map(Type.UNSIGNED_BYTE);
            // Slot
            map(Type.SHORT);
            // Button
            map(Type.BYTE);
            // Action id - removed
            map(Type.SHORT, Type.NOTHING);
            // Mode
            map(Type.VAR_INT);
            handler(wrapper -> {
                // The 1.17 client would check the entire inventory for changes before -> after a click and send the changed slots here
                // Empty array of slot+item
                wrapper.write(Type.VAR_INT, 0);
                // Expected is the carried item after clicking, old clients send the clicked one (*mostly* being the same)
                handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
            });
        }
    });
    protocol.registerServerbound(ServerboundPackets1_16_2.WINDOW_CONFIRMATION, null, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> {
                wrapper.cancel();
                if (!ViaBackwards.getConfig().handlePingsAsInvAcknowledgements()) {
                    return;
                }
                // Handle ping packet replacement
                short inventoryId = wrapper.read(Type.UNSIGNED_BYTE);
                short confirmationId = wrapper.read(Type.SHORT);
                boolean accepted = wrapper.read(Type.BOOLEAN);
                if (inventoryId == 0 && accepted && wrapper.user().get(PingRequests.class).removeId(confirmationId)) {
                    PacketWrapper pongPacket = wrapper.create(ServerboundPackets1_17.PONG);
                    pongPacket.write(Type.INT, (int) confirmationId);
                    pongPacket.sendToServer(Protocol1_16_4To1_17.class);
                }
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_17.SPAWN_PARTICLE, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Particle id
            map(Type.INT);
            // Long distance
            map(Type.BOOLEAN);
            // X
            map(Type.DOUBLE);
            // Y
            map(Type.DOUBLE);
            // Z
            map(Type.DOUBLE);
            // Offset X
            map(Type.FLOAT);
            // Offset Y
            map(Type.FLOAT);
            // Offset Z
            map(Type.FLOAT);
            // Particle data
            map(Type.FLOAT);
            // Particle count
            map(Type.INT);
            handler(wrapper -> {
                int id = wrapper.get(Type.INT, 0);
                if (id == 16) {
                    // R
                    wrapper.passthrough(Type.FLOAT);
                    // G
                    wrapper.passthrough(Type.FLOAT);
                    // B
                    wrapper.passthrough(Type.FLOAT);
                    // Scale
                    wrapper.passthrough(Type.FLOAT);
                    // Dust color transition -> Dust
                    // R
                    wrapper.read(Type.FLOAT);
                    // G
                    wrapper.read(Type.FLOAT);
                    // B
                    wrapper.read(Type.FLOAT);
                } else if (id == 37) {
                    // Vibration signal - no nice mapping possible without tracking entity positions and doing particle tasks
                    wrapper.set(Type.INT, 0, -1);
                    wrapper.cancel();
                }
            });
            handler(getSpawnParticleHandler(Type.FLAT_VAR_INT_ITEM));
        }
    });
    protocol.mergePacket(ClientboundPackets1_17.WORLD_BORDER_SIZE, ClientboundPackets1_16_2.WORLD_BORDER, 0);
    protocol.mergePacket(ClientboundPackets1_17.WORLD_BORDER_LERP_SIZE, ClientboundPackets1_16_2.WORLD_BORDER, 1);
    protocol.mergePacket(ClientboundPackets1_17.WORLD_BORDER_CENTER, ClientboundPackets1_16_2.WORLD_BORDER, 2);
    protocol.mergePacket(ClientboundPackets1_17.WORLD_BORDER_INIT, ClientboundPackets1_16_2.WORLD_BORDER, 3);
    protocol.mergePacket(ClientboundPackets1_17.WORLD_BORDER_WARNING_DELAY, ClientboundPackets1_16_2.WORLD_BORDER, 4);
    protocol.mergePacket(ClientboundPackets1_17.WORLD_BORDER_WARNING_DISTANCE, ClientboundPackets1_16_2.WORLD_BORDER, 5);
    // The Great Shrunkening
    // Chunk sections *will* be lost ¯\_(ツ)_/¯
    protocol.registerClientbound(ClientboundPackets1_17.UPDATE_LIGHT, new PacketRemapper() {

        @Override
        public void registerMap() {
            // X
            map(Type.VAR_INT);
            // Z
            map(Type.VAR_INT);
            // Trust edges
            map(Type.BOOLEAN);
            handler(wrapper -> {
                EntityTracker tracker = wrapper.user().getEntityTracker(Protocol1_16_4To1_17.class);
                int startFromSection = Math.max(0, -(tracker.currentMinY() >> 4));
                long[] skyLightMask = wrapper.read(Type.LONG_ARRAY_PRIMITIVE);
                long[] blockLightMask = wrapper.read(Type.LONG_ARRAY_PRIMITIVE);
                int cutSkyLightMask = cutLightMask(skyLightMask, startFromSection);
                int cutBlockLightMask = cutLightMask(blockLightMask, startFromSection);
                wrapper.write(Type.VAR_INT, cutSkyLightMask);
                wrapper.write(Type.VAR_INT, cutBlockLightMask);
                long[] emptySkyLightMask = wrapper.read(Type.LONG_ARRAY_PRIMITIVE);
                long[] emptyBlockLightMask = wrapper.read(Type.LONG_ARRAY_PRIMITIVE);
                wrapper.write(Type.VAR_INT, cutLightMask(emptySkyLightMask, startFromSection));
                wrapper.write(Type.VAR_INT, cutLightMask(emptyBlockLightMask, startFromSection));
                writeLightArrays(wrapper, BitSet.valueOf(skyLightMask), cutSkyLightMask, startFromSection, tracker.currentWorldSectionHeight());
                writeLightArrays(wrapper, BitSet.valueOf(blockLightMask), cutBlockLightMask, startFromSection, tracker.currentWorldSectionHeight());
            });
        }

        private void writeLightArrays(PacketWrapper wrapper, BitSet bitMask, int cutBitMask, int startFromSection, int sectionHeight) throws Exception {
            // Length - throw it away
            wrapper.read(Type.VAR_INT);
            List<byte[]> light = new ArrayList<>();
            // Remove lower bounds
            for (int i = 0; i < startFromSection; i++) {
                if (bitMask.get(i)) {
                    wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
                }
            }
            // Add the important 18 sections
            for (int i = 0; i < 18; i++) {
                if (isSet(cutBitMask, i)) {
                    light.add(wrapper.read(Type.BYTE_ARRAY_PRIMITIVE));
                }
            }
            // Remove upper bounds
            for (int i = startFromSection + 18; i < sectionHeight + 2; i++) {
                if (bitMask.get(i)) {
                    wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
                }
            }
            // Aaand we're done
            for (byte[] bytes : light) {
                wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, bytes);
            }
        }

        private boolean isSet(int mask, int i) {
            return (mask & (1 << i)) != 0;
        }
    });
    protocol.registerClientbound(ClientboundPackets1_17.MULTI_BLOCK_CHANGE, new PacketRemapper() {

        public void registerMap() {
            // Chunk pos
            map(Type.LONG);
            // Suppress light updates
            map(Type.BOOLEAN);
            handler((wrapper) -> {
                // Remove sections below y 0 and above 255
                long chunkPos = wrapper.get(Type.LONG, 0);
                int chunkY = (int) (chunkPos << 44 >> 44);
                if (chunkY < 0 || chunkY > 15) {
                    wrapper.cancel();
                    return;
                }
                BlockChangeRecord[] records = wrapper.passthrough(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY);
                for (BlockChangeRecord record : records) {
                    record.setBlockId(protocol.getMappingData().getNewBlockStateId(record.getBlockId()));
                }
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_17.BLOCK_CHANGE, new PacketRemapper() {

        public void registerMap() {
            map(Type.POSITION1_14);
            map(Type.VAR_INT);
            handler((wrapper) -> {
                int y = wrapper.get(Type.POSITION1_14, 0).getY();
                if (y < 0 || y > 255) {
                    wrapper.cancel();
                    return;
                }
                wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.VAR_INT, 0)));
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_17.CHUNK_DATA, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> {
                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);
                // Cut sections
                int startFromSection = Math.max(0, -(tracker.currentMinY() >> 4));
                chunk.setBiomeData(Arrays.copyOfRange(chunk.getBiomeData(), startFromSection * 64, (startFromSection * 64) + 1024));
                chunk.setBitmask(cutMask(chunk.getChunkMask(), startFromSection, false));
                chunk.setChunkMask(null);
                ChunkSection[] sections = Arrays.copyOfRange(chunk.getSections(), startFromSection, startFromSection + 16);
                chunk.setSections(sections);
                CompoundTag heightMaps = chunk.getHeightMap();
                for (Tag heightMapTag : heightMaps.values()) {
                    LongArrayTag heightMap = (LongArrayTag) heightMapTag;
                    int[] heightMapData = new int[256];
                    int bitsPerEntry = MathUtil.ceilLog2((currentWorldSectionHeight << 4) + 1);
                    // Shift back to 0 based and clamp to normal height with 9 bits
                    CompactArrayUtil.iterateCompactArrayWithPadding(bitsPerEntry, heightMapData.length, heightMap.getValue(), (i, v) -> heightMapData[i] = MathUtil.clamp(v + tracker.currentMinY(), 0, 255));
                    heightMap.setValue(CompactArrayUtil.createCompactArrayWithPadding(9, heightMapData.length, i -> heightMapData[i]));
                }
                for (int i = 0; i < 16; i++) {
                    ChunkSection section = sections[i];
                    if (section == null)
                        continue;
                    for (int j = 0; j < section.getPaletteSize(); j++) {
                        int old = section.getPaletteEntry(j);
                        section.setPaletteEntry(j, protocol.getMappingData().getNewBlockStateId(old));
                    }
                }
                chunk.getBlockEntities().removeIf(compound -> {
                    NumberTag tag = compound.get("y");
                    return tag != null && tag.asInt() < 0;
                });
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_17.BLOCK_ENTITY_DATA, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> {
                int y = wrapper.passthrough(Type.POSITION1_14).getY();
                if (y < 0 || y > 255) {
                    wrapper.cancel();
                }
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_17.BLOCK_BREAK_ANIMATION, new PacketRemapper() {

        @Override
        public void registerMap() {
            map(Type.VAR_INT);
            handler(wrapper -> {
                int y = wrapper.passthrough(Type.POSITION1_14).getY();
                if (y < 0 || y > 255) {
                    wrapper.cancel();
                }
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_17.MAP_DATA, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Map ID
            map(Type.VAR_INT);
            // Scale
            map(Type.BYTE);
            // Tracking position
            handler(wrapper -> wrapper.write(Type.BOOLEAN, true));
            // Locked
            map(Type.BOOLEAN);
            handler(wrapper -> {
                boolean hasMarkers = wrapper.read(Type.BOOLEAN);
                if (!hasMarkers) {
                    // Array size
                    wrapper.write(Type.VAR_INT, 0);
                } else {
                    MapColorRewriter.getRewriteHandler(MapColorRewrites::getMappedColor).handle(wrapper);
                }
            });
        }
    });
}
Also used : ClientboundPackets1_17(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17) MathUtil(com.viaversion.viaversion.util.MathUtil) Arrays(java.util.Arrays) ServerboundPackets1_17(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17) PingRequests(com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.storage.PingRequests) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) LongArrayTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag) ArrayList(java.util.ArrayList) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) Type(com.viaversion.viaversion.api.type.Type) Chunk1_17Type(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type) Chunk(com.viaversion.viaversion.api.minecraft.chunks.Chunk) MapColorRewrites(com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.data.MapColorRewrites) MapColorRewriter(com.viaversion.viabackwards.api.rewriters.MapColorRewriter) Protocol1_16_4To1_17(com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4To1_17) Tag(com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag) EntityTracker(com.viaversion.viaversion.api.data.entity.EntityTracker) BlockChangeRecord(com.viaversion.viaversion.api.minecraft.BlockChangeRecord) CompactArrayUtil(com.viaversion.viaversion.util.CompactArrayUtil) ClientboundPackets1_16_2(com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2) NumberTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag) List(java.util.List) ServerboundPackets1_16_2(com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2) BlockRewriter(com.viaversion.viaversion.rewriter.BlockRewriter) ItemRewriter(com.viaversion.viabackwards.api.rewriters.ItemRewriter) Chunk1_16_2Type(com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type) ViaBackwards(com.viaversion.viabackwards.ViaBackwards) CompoundTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag) ChunkSection(com.viaversion.viaversion.api.minecraft.chunks.ChunkSection) BitSet(java.util.BitSet) RecipeRewriter1_16(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16) Chunk1_17Type(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type) RecipeRewriter1_16(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16) PingRequests(com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.storage.PingRequests) EntityTracker(com.viaversion.viaversion.api.data.entity.EntityTracker) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) BitSet(java.util.BitSet) MapColorRewrites(com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.data.MapColorRewrites) Chunk(com.viaversion.viaversion.api.minecraft.chunks.Chunk) BlockRewriter(com.viaversion.viaversion.rewriter.BlockRewriter) BlockChangeRecord(com.viaversion.viaversion.api.minecraft.BlockChangeRecord) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) LongArrayTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag) NumberTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag) ArrayList(java.util.ArrayList) List(java.util.List) Chunk1_16_2Type(com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type) LongArrayTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag) Tag(com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag) NumberTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag) CompoundTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag) Protocol1_16_4To1_17(com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4To1_17) ChunkSection(com.viaversion.viaversion.api.minecraft.chunks.ChunkSection) CompoundTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag)

Example 5 with EntityTracker

use of com.viaversion.viaversion.api.data.entity.EntityTracker in project ViaBackwards by ViaVersion.

the class BlockItemPackets1_18 method registerPackets.

@Override
protected void registerPackets() {
    new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_18.DECLARE_RECIPES);
    registerSetCooldown(ClientboundPackets1_18.COOLDOWN);
    registerWindowItems1_17_1(ClientboundPackets1_18.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, Type.FLAT_VAR_INT_ITEM);
    registerSetSlot1_17_1(ClientboundPackets1_18.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
    registerEntityEquipmentArray(ClientboundPackets1_18.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
    registerTradeList(ClientboundPackets1_18.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
    registerAdvancements(ClientboundPackets1_18.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
    registerClickWindow1_17_1(ServerboundPackets1_17.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
    protocol.registerClientbound(ClientboundPackets1_18.EFFECT, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Effect id
            map(Type.INT);
            // Location
            map(Type.POSITION1_14);
            // Data
            map(Type.INT);
            handler(wrapper -> {
                int id = wrapper.get(Type.INT, 0);
                int data = wrapper.get(Type.INT, 1);
                if (id == 1010) {
                    // Play record
                    wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(data));
                }
            });
        }
    });
    registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
    protocol.registerClientbound(ClientboundPackets1_18.SPAWN_PARTICLE, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Particle id
            map(Type.INT);
            // Override limiter
            map(Type.BOOLEAN);
            // X
            map(Type.DOUBLE);
            // Y
            map(Type.DOUBLE);
            // Z
            map(Type.DOUBLE);
            // Offset X
            map(Type.FLOAT);
            // Offset Y
            map(Type.FLOAT);
            // Offset Z
            map(Type.FLOAT);
            // Max speed
            map(Type.FLOAT);
            // Particle Count
            map(Type.INT);
            handler(wrapper -> {
                int id = wrapper.get(Type.INT, 0);
                if (id == 3) {
                    // Block marker
                    int blockState = wrapper.read(Type.VAR_INT);
                    if (blockState == 7786) {
                        // Light block
                        wrapper.set(Type.INT, 0, 3);
                    } else {
                        // Else assume barrier block
                        wrapper.set(Type.INT, 0, 2);
                    }
                    return;
                }
                ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
                if (mappings.isBlockParticle(id)) {
                    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));
                }
                int newId = protocol.getMappingData().getNewParticleId(id);
                if (newId != id) {
                    wrapper.set(Type.INT, 0, newId);
                }
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_18.BLOCK_ENTITY_DATA, new PacketRemapper() {

        @Override
        public void registerMap() {
            map(Type.POSITION1_14);
            handler(wrapper -> {
                final int id = wrapper.read(Type.VAR_INT);
                final CompoundTag tag = wrapper.read(Type.NBT);
                final int mappedId = BlockEntityIds.mappedId(id);
                if (mappedId == -1) {
                    wrapper.cancel();
                    return;
                }
                final String identifier = protocol.getMappingData().blockEntities().get(id);
                if (identifier == null) {
                    wrapper.cancel();
                    return;
                }
                // The 1.18 server doesn't include the id and positions (x, y, z) in the NBT anymore
                // If those were the only fields on the block entity (e.g.: skull, bed), we'll receive a null NBT
                // We initialize one and add the missing fields, so it can be handled correctly down the line
                final CompoundTag newTag = tag == null ? new CompoundTag() : tag;
                final Position pos = wrapper.get(Type.POSITION1_14, 0);
                // The protocol converters downstream rely on this field, let's add it back
                newTag.put("id", new StringTag("minecraft:" + identifier));
                // Weird glitches happen with the 1.17 client and below if these fields are missing
                // Some examples are block entity models becoming invisible (e.g.: signs, banners)
                newTag.put("x", new IntTag(pos.x()));
                newTag.put("y", new IntTag(pos.y()));
                newTag.put("z", new IntTag(pos.z()));
                handleSpawner(id, newTag);
                wrapper.write(Type.UNSIGNED_BYTE, (short) mappedId);
                wrapper.write(Type.NBT, newTag);
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_18.CHUNK_DATA, new PacketRemapper() {

        @Override
        public void registerMap() {
            handler(wrapper -> {
                final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
                final Chunk1_18Type chunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(), MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().size()), MathUtil.ceilLog2(tracker.biomesSent()));
                final Chunk oldChunk = wrapper.read(chunkType);
                final ChunkSection[] sections = oldChunk.getSections();
                final BitSet mask = new BitSet(oldChunk.getSections().length);
                final int[] biomeData = new int[sections.length * ChunkSection.BIOME_SIZE];
                int biomeIndex = 0;
                for (int j = 0; j < sections.length; j++) {
                    final ChunkSection section = sections[j];
                    // Write biome palette into biome array
                    final DataPalette biomePalette = section.palette(PaletteType.BIOMES);
                    for (int i = 0; i < ChunkSection.BIOME_SIZE; i++) {
                        biomeData[biomeIndex++] = biomePalette.idAt(i);
                    }
                    // Rewrite to empty section
                    if (section.getNonAirBlocksCount() == 0) {
                        sections[j] = null;
                    } else {
                        mask.set(j);
                    }
                }
                final List<CompoundTag> blockEntityTags = new ArrayList<>(oldChunk.blockEntities().size());
                for (final BlockEntity blockEntity : oldChunk.blockEntities()) {
                    final String id = protocol.getMappingData().blockEntities().get(blockEntity.typeId());
                    if (id == null) {
                        // Shrug
                        continue;
                    }
                    final CompoundTag tag;
                    if (blockEntity.tag() != null) {
                        tag = blockEntity.tag();
                        handleSpawner(blockEntity.typeId(), tag);
                    } else {
                        tag = new CompoundTag();
                    }
                    blockEntityTags.add(tag);
                    tag.put("x", new IntTag((oldChunk.getX() << 4) + blockEntity.sectionX()));
                    tag.put("y", new IntTag(blockEntity.y()));
                    tag.put("z", new IntTag((oldChunk.getZ() << 4) + blockEntity.sectionZ()));
                    tag.put("id", new StringTag("minecraft:" + id));
                }
                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);
                // Create and send light packet first
                final PacketWrapper lightPacket = wrapper.create(ClientboundPackets1_17_1.UPDATE_LIGHT);
                lightPacket.write(Type.VAR_INT, chunk.getX());
                lightPacket.write(Type.VAR_INT, chunk.getZ());
                // Trust edges
                lightPacket.write(Type.BOOLEAN, wrapper.read(Type.BOOLEAN));
                // Sky light mask
                lightPacket.write(Type.LONG_ARRAY_PRIMITIVE, wrapper.read(Type.LONG_ARRAY_PRIMITIVE));
                // Block light mask
                lightPacket.write(Type.LONG_ARRAY_PRIMITIVE, wrapper.read(Type.LONG_ARRAY_PRIMITIVE));
                // Empty sky light mask
                lightPacket.write(Type.LONG_ARRAY_PRIMITIVE, wrapper.read(Type.LONG_ARRAY_PRIMITIVE));
                // Empty block light mask
                lightPacket.write(Type.LONG_ARRAY_PRIMITIVE, wrapper.read(Type.LONG_ARRAY_PRIMITIVE));
                final int skyLightLength = wrapper.read(Type.VAR_INT);
                lightPacket.write(Type.VAR_INT, skyLightLength);
                for (int i = 0; i < skyLightLength; i++) {
                    lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, wrapper.read(Type.BYTE_ARRAY_PRIMITIVE));
                }
                final int blockLightLength = wrapper.read(Type.VAR_INT);
                lightPacket.write(Type.VAR_INT, blockLightLength);
                for (int i = 0; i < blockLightLength; i++) {
                    lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, wrapper.read(Type.BYTE_ARRAY_PRIMITIVE));
                }
                lightPacket.send(Protocol1_17_1To1_18.class);
            });
        }
    });
    protocol.cancelClientbound(ClientboundPackets1_18.SET_SIMULATION_DISTANCE);
}
Also used : MathUtil(com.viaversion.viaversion.util.MathUtil) ServerboundPackets1_17(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) ArrayList(java.util.ArrayList) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) Type(com.viaversion.viaversion.api.type.Type) Chunk1_17Type(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type) Chunk(com.viaversion.viaversion.api.minecraft.chunks.Chunk) Protocol1_17_1To1_18(com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18) ClientboundPackets1_17_1(com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1) PaletteType(com.viaversion.viaversion.api.minecraft.chunks.PaletteType) IntTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag) Chunk1_18Type(com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type) BlockEntity(com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity) Position(com.viaversion.viaversion.api.minecraft.Position) ClientboundPackets1_18(com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18) BlockEntityIds(com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.data.BlockEntityIds) BaseChunk(com.viaversion.viaversion.api.minecraft.chunks.BaseChunk) EntityTracker(com.viaversion.viaversion.api.data.entity.EntityTracker) StringTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag) DataPalette(com.viaversion.viaversion.api.minecraft.chunks.DataPalette) List(java.util.List) ItemRewriter(com.viaversion.viabackwards.api.rewriters.ItemRewriter) ParticleMappings(com.viaversion.viaversion.api.data.ParticleMappings) CompoundTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag) ChunkSection(com.viaversion.viaversion.api.minecraft.chunks.ChunkSection) BitSet(java.util.BitSet) RecipeRewriter1_16(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16) StringTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag) BaseChunk(com.viaversion.viaversion.api.minecraft.chunks.BaseChunk) Chunk1_17Type(com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type) RecipeRewriter1_16(com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16) Position(com.viaversion.viaversion.api.minecraft.Position) EntityTracker(com.viaversion.viaversion.api.data.entity.EntityTracker) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) BitSet(java.util.BitSet) Protocol1_17_1To1_18(com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18) Chunk(com.viaversion.viaversion.api.minecraft.chunks.Chunk) BaseChunk(com.viaversion.viaversion.api.minecraft.chunks.BaseChunk) DataPalette(com.viaversion.viaversion.api.minecraft.chunks.DataPalette) Chunk1_18Type(com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) ArrayList(java.util.ArrayList) List(java.util.List) ParticleMappings(com.viaversion.viaversion.api.data.ParticleMappings) ChunkSection(com.viaversion.viaversion.api.minecraft.chunks.ChunkSection) CompoundTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag) IntTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag) BlockEntity(com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity)

Aggregations

EntityTracker (com.viaversion.viaversion.api.data.entity.EntityTracker)11 PacketRemapper (com.viaversion.viaversion.api.protocol.remapper.PacketRemapper)8 Type (com.viaversion.viaversion.api.type.Type)7 PacketWrapper (com.viaversion.viaversion.api.protocol.packet.PacketWrapper)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 EntityType (com.viaversion.viaversion.api.minecraft.entities.EntityType)3 ClientboundPackets1_17_1 (com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1)3 Chunk1_17Type (com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type)3 MathUtil (com.viaversion.viaversion.util.MathUtil)3 BitSet (java.util.BitSet)3 ViaBackwards (com.viaversion.viabackwards.ViaBackwards)2 ItemRewriter (com.viaversion.viabackwards.api.rewriters.ItemRewriter)2 WindowTracker (com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker)2 Via (com.viaversion.viaversion.api.Via)2 StoredEntityData (com.viaversion.viaversion.api.data.entity.StoredEntityData)2 Position (com.viaversion.viaversion.api.minecraft.Position)2 BlockEntity (com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity)2 Chunk (com.viaversion.viaversion.api.minecraft.chunks.Chunk)2 ChunkSection (com.viaversion.viaversion.api.minecraft.chunks.ChunkSection)2