Search in sources :

Example 1 with StringNBT

use of net.minecraft.nbt.StringNBT in project Enigmatic-Legacy by Aizistral-Studios.

the class OblivionStoneCombineRecipe method matches.

@Override
public boolean matches(CraftingInventory inv, World world) {
    List<ItemStack> stackList = new ArrayList<ItemStack>();
    ItemStack voidStone = null;
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack checkedItemStack = inv.getStackInSlot(i);
        if (!checkedItemStack.isEmpty()) {
            if (checkedItemStack.getItem() == EnigmaticLegacy.oblivionStone) {
                if (voidStone == null)
                    voidStone = checkedItemStack;
                else
                    return false;
            } else {
                stackList.add(checkedItemStack);
            }
        }
    }
    if (voidStone != null & stackList.size() == 1) {
        ItemStack savedStack = stackList.get(0).copy();
        CompoundNBT nbt = voidStone.getOrCreateTag();
        ListNBT arr = nbt.getList("SupersolidID", 8);
        int counter = 0;
        if (arr.size() >= ConfigHandler.OBLIVION_STONE_HARDCAP.getValue())
            return false;
        for (INBT s_uncast : arr) {
            counter++;
            String s = ((StringNBT) s_uncast).getString();
            if (s.equals(ForgeRegistries.ITEMS.getKey(savedStack.getItem()).toString()))
                return false;
        }
        return true;
    } else if (voidStone != null & stackList.size() == 0) {
        return true;
    } else
        return false;
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) INBT(net.minecraft.nbt.INBT) StringNBT(net.minecraft.nbt.StringNBT) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 2 with StringNBT

use of net.minecraft.nbt.StringNBT in project Enigmatic-Legacy by Aizistral-Studios.

the class ItemLoreHelper method setLoreString.

public static ItemStack setLoreString(ItemStack stack, String string, int index) {
    CompoundNBT nbt = stack.getOrCreateChildTag("display");
    ListNBT loreList = nbt.getList("Lore", 8);
    if (loreList.size() - 1 >= index)
        loreList.set(index, new StringNBT(ITextComponent.Serializer.toJson(new StringTextComponent(string))));
    else
        loreList.add(new StringNBT(ITextComponent.Serializer.toJson(new StringTextComponent(string))));
    nbt.put("Lore", loreList);
    return stack;
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) StringNBT(net.minecraft.nbt.StringNBT) StringTextComponent(net.minecraft.util.text.StringTextComponent)

Example 3 with StringNBT

use of net.minecraft.nbt.StringNBT in project Enigmatic-Legacy by Aizistral-Studios.

the class ItemLoreHelper method addLoreString.

public static ItemStack addLoreString(ItemStack stack, String string) {
    CompoundNBT nbt = stack.getOrCreateChildTag("display");
    ListNBT loreList = nbt.getList("Lore", 8);
    loreList.add(new StringNBT(ITextComponent.Serializer.toJson(new StringTextComponent(string))));
    nbt.put("Lore", loreList);
    return stack;
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) StringNBT(net.minecraft.nbt.StringNBT) StringTextComponent(net.minecraft.util.text.StringTextComponent)

Example 4 with StringNBT

use of net.minecraft.nbt.StringNBT in project ChocolateQuestRepoured by TeamChocoQuest.

the class ItemDungeonPlacer method getSubItems.

@Override
public void getSubItems(ItemGroup tab, NonNullList<ItemStack> items) {
    if (this.isInCreativeTab(tab)) {
        for (ClientDungeon fakeDungeon : CLIENT_DUNGEON_LIST) {
            int iconID = fakeDungeon.getIconID() <= HIGHEST_ICON_NUMBER ? fakeDungeon.getIconID() : 0;
            if (iconID == this.iconID) {
                ItemStack stack = new ItemStack(this);
                CompoundNBT compound = new CompoundNBT();
                compound.setString("dungeonName", fakeDungeon.getDungeonName());
                compound.setInteger("iconID", iconID);
                ListNBT dependencies = new ListNBT();
                for (String dependency : fakeDungeon.getDependencies()) {
                    dependencies.appendTag(new StringNBT(dependency));
                }
                compound.setTag("dependencies", dependencies);
                stack.setTagCompound(compound);
                items.add(stack);
            }
        }
    }
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) StringNBT(net.minecraft.nbt.StringNBT) ItemStack(net.minecraft.item.ItemStack)

Example 5 with StringNBT

use of net.minecraft.nbt.StringNBT in project ChocolateQuestRepoured by TeamChocoQuest.

the class NBTHelper method getVersionOfStructureFile.

public static String getVersionOfStructureFile(File file) {
    try (DataInputStream input = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file))))) {
        if (input.readByte() != Constants.NBT.TAG_COMPOUND) {
            return null;
        }
        input.readUTF();
        byte id;
        while ((id = input.readByte()) != 0) {
            String key = input.readUTF();
            INBT nbtbase = CompoundNBT.readNBT(id, key, input, 0, NBTSizeTracker.UNLIMITED);
            if (key.equals("cqr_file_version")) {
                return nbtbase instanceof StringNBT ? ((StringNBT) nbtbase).getAsString() : null;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) BufferedInputStream(java.io.BufferedInputStream) INBT(net.minecraft.nbt.INBT) StringNBT(net.minecraft.nbt.StringNBT) DataInputStream(java.io.DataInputStream) FileInputStream(java.io.FileInputStream)

Aggregations

StringNBT (net.minecraft.nbt.StringNBT)12 CompoundNBT (net.minecraft.nbt.CompoundNBT)9 ListNBT (net.minecraft.nbt.ListNBT)9 ItemStack (net.minecraft.item.ItemStack)5 INBT (net.minecraft.nbt.INBT)4 ArrayList (java.util.ArrayList)3 StringTextComponent (net.minecraft.util.text.StringTextComponent)3 HashMap (java.util.HashMap)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ServerWorld (net.minecraft.world.server.ServerWorld)2 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Multimap (com.google.common.collect.Multimap)1 StringReader (com.mojang.brigadier.StringReader)1 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 JigsawType (de.industria.blocks.BlockJigsaw.JigsawType)1 JigsawTemplateProcessor (de.industria.structureprocessor.JigsawTemplateProcessor)1 JigsawReplacement (de.industria.structureprocessor.JigsawTemplateProcessor.JigsawReplacement)1 Skill (jackiecrazy.wardance.skill.Skill)1 SkillData (jackiecrazy.wardance.skill.SkillData)1 BufferedInputStream (java.io.BufferedInputStream)1