Search in sources :

Example 36 with NbtElement

use of net.minecraft.nbt.NbtElement in project meteor-client by MeteorDevelopment.

the class Profile method fromTag.

@Override
public Profile fromTag(NbtCompound tag) {
    name = tag.getString("name");
    onLaunch = tag.contains("onLaunch") && tag.getBoolean("onLaunch");
    accounts = tag.contains("accounts") && tag.getBoolean("accounts");
    config = tag.contains("config") && tag.getBoolean("config");
    friends = tag.contains("friends") && tag.getBoolean("friends");
    macros = tag.contains("macros") && tag.getBoolean("macros");
    modules = tag.contains("modules") && tag.getBoolean("modules");
    waypoints = tag.contains("waypoints") && tag.getBoolean("waypoints");
    hud = tag.contains("hud") && tag.getBoolean("hud");
    loadOnJoinIps.clear();
    if (tag.contains("loadOnJoinIps")) {
        NbtList ipsTag = tag.getList("loadOnJoinIps", 8);
        for (NbtElement ip : ipsTag) loadOnJoinIps.add(ip.asString());
    }
    return this;
}
Also used : NbtList(net.minecraft.nbt.NbtList) NbtElement(net.minecraft.nbt.NbtElement)

Example 37 with NbtElement

use of net.minecraft.nbt.NbtElement in project bewitchment by MoriyaShiine.

the class BaphometEntity method readCustomDataFromNbt.

@Override
public void readCustomDataFromNbt(NbtCompound nbt) {
    super.readCustomDataFromNbt(nbt);
    if (hasCustomName()) {
        bossBar.setName(getDisplayName());
    }
    fromNbtPledgeable(nbt);
    if (nbt.contains("Offers")) {
        offers.clear();
        NbtList offersList = nbt.getList("Offers", NbtType.COMPOUND);
        for (NbtElement offerTag : offersList) {
            offers.add(new DemonEntity.DemonTradeOffer((NbtCompound) offerTag));
        }
    }
    tradeResetTimer = nbt.getInt("TradeResetTimer");
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) NbtElement(net.minecraft.nbt.NbtElement)

Example 38 with NbtElement

use of net.minecraft.nbt.NbtElement in project Polymorph by TheIllusiveC4.

the class AbstractRecipeData method readNbt.

@Override
public void readNbt(NbtCompound pCompound) {
    if (pCompound.contains("SelectedRecipe")) {
        this.loadedRecipe = new Identifier(pCompound.getString("SelectedRecipe"));
    }
    if (pCompound.contains("RecipeDataSet")) {
        Set<RecipePair> dataset = this.getRecipesList();
        dataset.clear();
        NbtList list = pCompound.getList("RecipeDataSet", NbtType.COMPOUND);
        for (NbtElement inbt : list) {
            NbtCompound tag = (NbtCompound) inbt;
            Identifier id = Identifier.tryParse(tag.getString("Id"));
            ItemStack stack = ItemStack.fromNbt(tag.getCompound("ItemStack"));
            dataset.add(new RecipePairImpl(id, stack));
        }
    }
}
Also used : Identifier(net.minecraft.util.Identifier) RecipePair(top.theillusivec4.polymorph.api.common.base.RecipePair) NbtCompound(net.minecraft.nbt.NbtCompound) RecipePairImpl(top.theillusivec4.polymorph.common.impl.RecipePairImpl) NbtList(net.minecraft.nbt.NbtList) NbtElement(net.minecraft.nbt.NbtElement) ItemStack(net.minecraft.item.ItemStack)

Example 39 with NbtElement

use of net.minecraft.nbt.NbtElement in project Primeval by devs-immortal.

the class VesselItem method processItems.

// 
// VESSEL-SPECIFIC METHODS
// 
public static ItemStack processItems(ItemStack vessel, World world) {
    NbtCompound nbt = vessel.getOrCreateNbt();
    NbtList nbtList = nbt.getList("Items", 10);
    // Create new hashmap to store fluids that will be inserted
    HashMap<FluidVariant, Integer> fluids = new HashMap<>();
    // Item being melted
    ItemStack itemStack;
    // Resulting fluid from melted item, being <type, quantity>
    Pair<FluidVariant, Integer> fluidResult;
    // Type of fluid result
    FluidVariant fluidType;
    // Amonut of fluid from melting
    int fluidAmount;
    for (NbtElement nbtC : nbtList) {
        // Get itemstack from item to melted
        itemStack = ItemStack.fromNbt((NbtCompound) nbtC);
        // Check if meltable recipe for the item
        Optional<MeltingRecipe> option = world.getRecipeManager().getFirstMatch(PrimevalRecipes.MELTING, new SimpleInventory(itemStack), world);
        if (option.isPresent()) {
            // if can be melted
            fluidResult = option.get().getFluidResult();
            fluidType = fluidResult.getLeft();
            fluidAmount = fluidResult.getRight();
            if (fluids.containsKey(fluidType)) {
                fluids.put(fluidType, fluids.get(fluidType) + fluidAmount * itemStack.getCount());
            } else {
                fluids.put(fluidType, fluidAmount * itemStack.getCount());
            }
        }
    }
    Pair<FluidVariant, Integer> alloyResult = PrimevalFluids.combineFluids(fluids);
    if (alloyResult.getRight() > 0) {
        NbtCompound nbtF = alloyResult.getLeft().toNbt();
        nbtF.putInt("Amount", alloyResult.getRight());
        nbt.put("Fluid", nbtF);
    }
    // Clear out items
    nbt.put("Items", new NbtList());
    vessel.setNbt(nbt);
    return vessel;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) HashMap(java.util.HashMap) FluidVariant(net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant) NbtElement(net.minecraft.nbt.NbtElement) MeltingRecipe(net.cr24.primeval.recipe.MeltingRecipe) NbtList(net.minecraft.nbt.NbtList) ItemStack(net.minecraft.item.ItemStack) SimpleInventory(net.minecraft.inventory.SimpleInventory)

Example 40 with NbtElement

use of net.minecraft.nbt.NbtElement in project meteor-rejects by AntiCope.

the class RejectsConfig method fromTag.

@Override
public RejectsConfig fromTag(NbtCompound tag) {
    httpAllowed = HttpAllowed.valueOf(tag.getString("httpAllowed"));
    checkForUpdates = !tag.contains("checkForUpdates") || tag.getBoolean("checkForUpdates");
    NbtList valueTag = tag.getList("hiddenModules", 8);
    for (NbtElement tagI : valueTag) {
        hiddenModules.add(tagI.asString());
    }
    return this;
}
Also used : NbtList(net.minecraft.nbt.NbtList) NbtElement(net.minecraft.nbt.NbtElement)

Aggregations

NbtElement (net.minecraft.nbt.NbtElement)51 NbtList (net.minecraft.nbt.NbtList)44 NbtCompound (net.minecraft.nbt.NbtCompound)22 Identifier (net.minecraft.util.Identifier)20 ItemStack (net.minecraft.item.ItemStack)6 Field (java.lang.reflect.Field)2 Block (net.minecraft.block.Block)2 Enchantment (net.minecraft.enchantment.Enchantment)2 StatusEffect (net.minecraft.entity.effect.StatusEffect)2 Item (net.minecraft.item.Item)2 SoundEvent (net.minecraft.sound.SoundEvent)2 DyeColor (net.minecraft.util.DyeColor)2 RecipePair (top.theillusivec4.polymorph.api.common.base.RecipePair)2 RecipePairImpl (top.theillusivec4.polymorph.common.impl.RecipePairImpl)2 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Module (mathax.client.systems.modules.Module)1 Module (meteordevelopment.meteorclient.systems.modules.Module)1