Search in sources :

Example 1 with ConditionInstance

use of com.lying.variousoddities.condition.ConditionInstance in project VariousOddities by Lyinginbedmon.

the class LivingData method deserializeNBT.

public void deserializeNBT(CompoundNBT nbt) {
    if (nbt.isEmpty()) {
        resetLivingData();
        return;
    }
    this.initialised = nbt.getBoolean("Initialised");
    if (nbt.contains("HomeDim", 8))
        this.originDimension = new ResourceLocation(nbt.getString("HomeDim"));
    this.air = nbt.getInt("Air");
    this.bludgeoning = nbt.getFloat("Bludgeoning");
    this.recoveryTimer = nbt.getInt("Recovery");
    this.isUnconscious = nbt.getBoolean("Unconscious");
    this.species = null;
    if (nbt.contains("Species", 10)) {
        CompoundNBT speciesData = nbt.getCompound("Species");
        this.species = SpeciesRegistry.instanceFromNBT(speciesData);
    }
    this.selectedSpecies = nbt.getBoolean("SelectedSpecies");
    this.templates.clear();
    if (nbt.contains("Templates", 9)) {
        ListNBT templateList = nbt.getList("Templates", 8);
        for (int i = 0; i < templateList.size(); i++) {
            ResourceLocation registryName = new ResourceLocation(templateList.getString(i));
            if (VORegistries.TEMPLATES.containsKey(registryName))
                this.templates.put(registryName, VORegistries.TEMPLATES.get(registryName));
        }
    }
    ListNBT types = nbt.getList("Types", 8);
    prevTypes.clear();
    for (int i = 0; i < types.size(); i++) prevTypes.add(EnumCreatureType.fromName(types.getString(i)));
    this.customTypes.clear();
    if (nbt.contains("CustomTypes", 9)) {
        ListNBT customTypes = nbt.getList("CustomTypes", 8);
        for (int i = 0; i < customTypes.size(); i++) this.customTypes.add(EnumCreatureType.fromName(types.getString(i)));
    }
    this.abilities.deserializeNBT(nbt.getCompound("Abilities"));
    if (nbt.contains("Conditions", 9)) {
        ListNBT conditionList = nbt.getList("Conditions", 10);
        for (int i = 0; i < conditionList.size(); i++) {
            ConditionInstance instance = ConditionInstance.read(conditionList.getCompound(i));
            if (instance != null)
                this.conditions.add(instance);
        }
    }
    this.visualPotions = nbt.getByte("Potions");
    if (nbt.contains("Pockets", 10)) {
        ListNBT pocketItems = nbt.getList("Pockets", 10);
        for (int i = 0; i < 6; i++) {
            CompoundNBT stackData = pocketItems.getCompound(i);
            this.pockets.set(i, ItemStack.read(stackData));
        }
    }
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) ResourceLocation(net.minecraft.util.ResourceLocation) ConditionInstance(com.lying.variousoddities.condition.ConditionInstance)

Aggregations

ConditionInstance (com.lying.variousoddities.condition.ConditionInstance)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 ListNBT (net.minecraft.nbt.ListNBT)1 ResourceLocation (net.minecraft.util.ResourceLocation)1