Search in sources :

Example 1 with NbtList

use of net.minecraft.nbt.NbtList in project MasaGadget by plusls.

the class BborProtocol method parse.

public static void parse(PacketByteBuf buf) {
    Identifier dimensionId = buf.readIdentifier();
    ModInfo.LOGGER.debug("dimensionId = {}", dimensionId.toString());
    NbtCompound tag = BoundingBoxDeserializer.deserializeStructure(buf);
    if (!structuresCache.containsKey(dimensionId)) {
        structuresCache.put(dimensionId, new NbtList());
    }
    if (tag != null) {
        structuresCache.get(dimensionId).add(tag);
        if (enable && Configs.Minihud.COMPACT_BBOR_PROTOCOL.getBooleanValue() && MinecraftClient.getInstance().world != null) {
            BborProtocol.lock.lock();
            try {
                DataStorage.getInstance().addOrUpdateStructuresFromServer(structuresCache.get(dimensionId), 0x7fffffff - 0x1000, false);
            } catch (Exception e) {
                e.printStackTrace();
            }
            BborProtocol.lock.unlock();
        }
    }
}
Also used : Identifier(net.minecraft.util.Identifier) NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList)

Example 2 with NbtList

use of net.minecraft.nbt.NbtList in project MasaGadget by plusls.

the class BborProtocol method bborRefreshData.

public static void bborRefreshData(Identifier dimensionId) {
    if (!structuresCache.containsKey(dimensionId)) {
        structuresCache.put(dimensionId, new NbtList());
    }
    BborProtocol.lock.lock();
    try {
        DataStorage.getInstance().addOrUpdateStructuresFromServer(BborProtocol.structuresCache.get(dimensionId), 0x7fffffff - 0x1000, false);
    } catch (Exception e) {
        e.printStackTrace();
    }
    BborProtocol.lock.unlock();
}
Also used : NbtList(net.minecraft.nbt.NbtList)

Example 3 with NbtList

use of net.minecraft.nbt.NbtList in project MasaGadget by plusls.

the class BoundingBoxDeserializer method deserializeStructure.

public static NbtCompound deserializeStructure(PacketByteBuf buf) {
    NbtCompound tag = new NbtCompound();
    deserializeStructureBox(buf, tag, true);
    if (!tag.contains("BB")) {
        return null;
    }
    NbtList childrenTagList = new NbtList();
    while (buf.isReadable()) {
        NbtCompound childrenTag = new NbtCompound();
        deserializeStructureBox(buf, childrenTag, false);
        childrenTagList.add(childrenTag);
    }
    tag.put("Children", childrenTagList);
    return tag;
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList)

Example 4 with NbtList

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

the class AbstractStackRecipeData 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 5 with NbtList

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

the class VesselItem method removeFirstStack.

private static Optional<ItemStack> removeFirstStack(ItemStack stack) {
    NbtCompound nbtCompound = stack.getOrCreateNbt();
    if (!nbtCompound.contains("Items")) {
        return Optional.empty();
    } else {
        NbtList nbtList = nbtCompound.getList("Items", 10);
        if (nbtList.isEmpty()) {
            return Optional.empty();
        } else {
            NbtCompound nbtCompound2 = nbtList.getCompound(0);
            ItemStack itemStack = ItemStack.fromNbt(nbtCompound2);
            nbtList.remove(0);
            if (nbtList.isEmpty()) {
                stack.removeSubNbt("Items");
            }
            return Optional.of(itemStack);
        }
    }
}
Also used : NbtCompound(net.minecraft.nbt.NbtCompound) NbtList(net.minecraft.nbt.NbtList) ItemStack(net.minecraft.item.ItemStack)

Aggregations

NbtList (net.minecraft.nbt.NbtList)146 NbtCompound (net.minecraft.nbt.NbtCompound)79 NbtElement (net.minecraft.nbt.NbtElement)45 Identifier (net.minecraft.util.Identifier)37 ItemStack (net.minecraft.item.ItemStack)25 NbtString (net.minecraft.nbt.NbtString)16 LiteralText (net.minecraft.text.LiteralText)12 BlockPos (net.minecraft.util.math.BlockPos)11 Block (net.minecraft.block.Block)9 List (java.util.List)8 Item (net.minecraft.item.Item)7 Inject (org.spongepowered.asm.mixin.injection.Inject)7 IOException (java.io.IOException)6 Items (net.minecraft.item.Items)6 NbtIo (net.minecraft.nbt.NbtIo)6 StatusEffect (net.minecraft.entity.effect.StatusEffect)5 Text (net.minecraft.text.Text)5 Comparator (java.util.Comparator)4 Blocks (net.minecraft.block.Blocks)4 EntityType (net.minecraft.entity.EntityType)4