All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.network.protocol.UnlockedRecipesPacket Maven / Gradle / Ivy

There is a newer version: 1.20.40-r1
Show newest version
package cn.nukkit.network.protocol;

import cn.nukkit.api.PowerNukkitXOnly;
import cn.nukkit.api.Since;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import lombok.Getter;

import java.util.List;

@Since("1.19.70-r1")
@PowerNukkitXOnly
@Getter
public class UnlockedRecipesPacket extends DataPacket {
    private boolean unlockedNotification;
    private final List unlockedRecipes = new ObjectArrayList<>();

    @Override
    public byte pid() {
        return ProtocolInfo.UNLOCKED_RECIPES_PACKET;
    }

    @Override
    public void decode() {
        this.unlockedNotification = this.getBoolean();
        int count = (int) this.getUnsignedVarInt();
        for (int i = 0; i < count; i++) {
            this.unlockedRecipes.add(this.getString());
        }
    }

    @Override
    public void encode() {
        this.reset();
        this.putBoolean(this.unlockedNotification);
        this.putUnsignedVarInt(this.unlockedRecipes.size());
        for (String recipe : this.unlockedRecipes) {
            this.putString(recipe);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy