Search in sources :

Example 1 with FloatTag

use of com.viaversion.viaversion.libs.opennbt.tag.builtin.FloatTag in project ViaBackwards by ViaVersion.

the class EntityPackets1_18 method registerPackets.

@Override
protected void registerPackets() {
    registerMetadataRewriter(ClientboundPackets1_18.ENTITY_METADATA, Types1_18.METADATA_LIST, Types1_17.METADATA_LIST);
    protocol.registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Entity ID
            map(Type.INT);
            // Hardcore
            map(Type.BOOLEAN);
            // Gamemode
            map(Type.UNSIGNED_BYTE);
            // Previous Gamemode
            map(Type.BYTE);
            // Worlds
            map(Type.STRING_ARRAY);
            // Dimension registry
            map(Type.NBT);
            // Current dimension data
            map(Type.NBT);
            // World
            map(Type.STRING);
            // Seed
            map(Type.LONG);
            // Max players
            map(Type.VAR_INT);
            // Chunk radius
            map(Type.VAR_INT);
            // Read simulation distance
            read(Type.VAR_INT);
            handler(worldDataTrackerHandler(1));
            handler(wrapper -> {
                final CompoundTag registry = wrapper.get(Type.NBT, 0);
                final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
                final ListTag biomes = biomeRegistry.get("value");
                for (final Tag biome : biomes.getValue()) {
                    final CompoundTag biomeCompound = ((CompoundTag) biome).get("element");
                    final StringTag category = biomeCompound.get("category");
                    if (category.getValue().equals("mountain")) {
                        category.setValue("extreme_hills");
                    }
                    // The client just needs something
                    biomeCompound.put("depth", new FloatTag(0.125F));
                    biomeCompound.put("scale", new FloatTag(0.05F));
                }
                // Track amount of biomes sent
                tracker(wrapper.user()).setBiomesSent(biomes.size());
            });
        }
    });
    protocol.registerClientbound(ClientboundPackets1_18.RESPAWN, new PacketRemapper() {

        @Override
        public void registerMap() {
            // Dimension data
            map(Type.NBT);
            // World
            map(Type.STRING);
            handler(worldDataTrackerHandler(0));
        }
    });
}
Also used : Particle(com.viaversion.viaversion.api.type.types.Particle) ClientboundPackets1_18(com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18) MetaType(com.viaversion.viaversion.api.minecraft.metadata.MetaType) Tag(com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag) EntityType(com.viaversion.viaversion.api.minecraft.entities.EntityType) StringTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag) ListTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag) Types1_17(com.viaversion.viaversion.api.type.types.version.Types1_17) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) Type(com.viaversion.viaversion.api.type.Type) Types1_18(com.viaversion.viaversion.api.type.types.version.Types1_18) Entity1_17Types(com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types) Protocol1_17_1To1_18(com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18) CompoundTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag) EntityRewriter(com.viaversion.viabackwards.api.rewriters.EntityRewriter) FloatTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.FloatTag) StringTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag) FloatTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.FloatTag) PacketRemapper(com.viaversion.viaversion.api.protocol.remapper.PacketRemapper) Tag(com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag) StringTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag) ListTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag) CompoundTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag) FloatTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.FloatTag) ListTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag) CompoundTag(com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag)

Aggregations

EntityRewriter (com.viaversion.viabackwards.api.rewriters.EntityRewriter)1 Protocol1_17_1To1_18 (com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18)1 Entity1_17Types (com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types)1 EntityType (com.viaversion.viaversion.api.minecraft.entities.EntityType)1 MetaType (com.viaversion.viaversion.api.minecraft.metadata.MetaType)1 PacketRemapper (com.viaversion.viaversion.api.protocol.remapper.PacketRemapper)1 Type (com.viaversion.viaversion.api.type.Type)1 Particle (com.viaversion.viaversion.api.type.types.Particle)1 Types1_17 (com.viaversion.viaversion.api.type.types.version.Types1_17)1 Types1_18 (com.viaversion.viaversion.api.type.types.version.Types1_18)1 CompoundTag (com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag)1 FloatTag (com.viaversion.viaversion.libs.opennbt.tag.builtin.FloatTag)1 ListTag (com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag)1 StringTag (com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag)1 Tag (com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag)1 ClientboundPackets1_18 (com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18)1