Search in sources :

Example 91 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project RecurrentComplex by Ivorforce.

the class Book method poem.

public static ItemStack poem(Random random) {
    ItemStack stack = new ItemStack(Items.WRITTEN_BOOK);
    Person author = Person.randomHuman(random, random.nextFloat() < 0.9f);
    Poem poem = Poem.randomPoem(random, 32, author);
    stack.setTagInfo("pages", NBTTagLists.write(bookPages(poem.getText()).stream().map(Book::toJSON).map(NBTTagString::new).collect(Collectors.toList())));
    stack.setTagInfo("author", new NBTTagString(author.getFullName()));
    stack.setTagInfo("title", new NBTTagString(poem.getTitle()));
    return stack;
}
Also used : Poem(ivorius.reccomplex.random.Poem) NBTTagString(net.minecraft.nbt.NBTTagString) ItemStack(net.minecraft.item.ItemStack) Person(ivorius.reccomplex.random.Person)

Example 92 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project RecurrentComplex by Ivorforce.

the class WorldScriptStructureGenerator method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound nbtTagCompound) {
    BlockPositions.writeToNBT("structureShift", structureShift, nbtTagCompound);
    nbtTagCompound.setBoolean("simpleMode", simpleMode);
    nbtTagCompound.setString("structureListID", structureListID);
    if (front != null)
        nbtTagCompound.setString("front", Directions.serialize(front));
    NBTTagList structureNBTList = new NBTTagList();
    for (String struc : structureNames) structureNBTList.appendTag(new NBTTagString(struc));
    nbtTagCompound.setTag("structures", structureNBTList);
    if (structureRotation != null)
        nbtTagCompound.setInteger("structureRotation", structureRotation);
    if (structureMirror != null)
        nbtTagCompound.setBoolean("structureMirror", structureMirror);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 93 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project LogisticsPipes by RS485.

the class LogisticsProgramCompilerTileEntity method update.

@Override
public void update() {
    super.update();
    if (MainProxy.isServer(world)) {
        if (currentTask != null) {
            wasAbleToConsumePower = false;
            for (EnumFacing dir : EnumFacing.VALUES) {
                if (dir == EnumFacing.UP)
                    continue;
                DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), dir);
                TileEntity tile = pos.getTileEntity(getWorld());
                if (!(tile instanceof LogisticsTileGenericPipe)) {
                    continue;
                }
                LogisticsTileGenericPipe tPipe = (LogisticsTileGenericPipe) tile;
                if (!(tPipe.pipe.getClass() == PipeItemsBasicLogistics.class)) {
                    continue;
                }
                CoreRoutedPipe pipe = (CoreRoutedPipe) tPipe.pipe;
                if (pipe.useEnergy(10)) {
                    if (taskType.equals("category")) {
                        taskProgress += 0.0005;
                    } else if (taskType.equals("program")) {
                        taskProgress += 0.0025;
                    } else if (taskType.equals("flash")) {
                        taskProgress += 0.01;
                    } else {
                        taskProgress += 1;
                    }
                    wasAbleToConsumePower = true;
                }
            }
            if (taskProgress >= 1) {
                if (taskType.equals("category")) {
                    NBTTagList list = getNBTTagListForKey("compilerCategories");
                    list.appendTag(new NBTTagString(currentTask.toString()));
                } else if (taskType.equals("program")) {
                    NBTTagList list = getNBTTagListForKey("compilerPrograms");
                    list.appendTag(new NBTTagString(currentTask.toString()));
                } else if (taskType.equals("flash")) {
                    if (!getInventory().getStackInSlot(1).isEmpty()) {
                        ItemStack programmer = getInventory().getStackInSlot(1);
                        if (!programmer.hasTagCompound()) {
                            programmer.setTagCompound(new NBTTagCompound());
                        }
                        programmer.getTagCompound().setString(ItemLogisticsProgrammer.RECIPE_TARGET, currentTask.toString());
                    }
                } else {
                    throw new UnsupportedOperationException(taskType);
                }
                taskType = "";
                currentTask = null;
                taskProgress = 0;
                wasAbleToConsumePower = false;
            }
            updateClient();
        }
    }
}
Also used : IGuiTileEntity(logisticspipes.interfaces.IGuiTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) NBTTagList(net.minecraft.nbt.NBTTagList) EnumFacing(net.minecraft.util.EnumFacing) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) NBTTagString(net.minecraft.nbt.NBTTagString) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) ItemStack(net.minecraft.item.ItemStack)

Example 94 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project LogisticsPipes by RS485.

the class LogisticsTileGenericSubMultiBlock method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    if (nbt.hasKey("MainPipePos_xPos")) {
        mainPipePos.clear();
        DoubleCoordinates pos = DoubleCoordinates.readFromNBT("MainPipePos_", nbt);
        if (pos != null) {
            mainPipePos.add(pos);
        }
    }
    if (nbt.hasKey("MainPipePosList")) {
        NBTTagList list = nbt.getTagList("MainPipePosList", new NBTTagCompound().getId());
        for (int i = 0; i < list.tagCount(); i++) {
            DoubleCoordinates pos = DoubleCoordinates.readFromNBT("MainPipePos_", list.getCompoundTagAt(i));
            if (pos != null) {
                mainPipePos.add(pos);
            }
        }
    }
    if (nbt.hasKey("SubTypeList")) {
        NBTTagList list = nbt.getTagList("SubTypeList", new NBTTagString().getId());
        subTypes.clear();
        for (int i = 0; i < list.tagCount(); i++) {
            String name = list.getStringTagAt(i);
            CoreMultiBlockPipe.SubBlockTypeForShare type = CoreMultiBlockPipe.SubBlockTypeForShare.valueOf(name);
            if (type != null) {
                subTypes.add(type);
            }
        }
    }
    mainPipe = null;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 95 with NBTTagString

use of net.minecraft.nbt.NBTTagString in project LogisticsPipes by RS485.

the class ItemModuleInformationManager method saveInformation.

public static void saveInformation(@Nonnull ItemStack stack, LogisticsModule module) {
    if (module == null) {
        return;
    }
    NBTTagCompound nbt = new NBTTagCompound();
    module.writeToNBT(nbt);
    if (nbt.equals(new NBTTagCompound())) {
        return;
    }
    if (MainProxy.isClient()) {
        NBTTagList list = new NBTTagList();
        String info1 = "Please reopen the window";
        String info2 = "to see the information.";
        list.appendTag(new NBTTagString(info1));
        list.appendTag(new NBTTagString(info2));
        if (!stack.hasTagCompound()) {
            stack.setTagCompound(new NBTTagCompound());
        }
        NBTTagCompound tag = Objects.requireNonNull(stack.getTagCompound());
        tag.setTag("informationList", list);
        tag.setDouble("Random-Stack-Prevent", new Random().nextDouble());
        return;
    }
    if (!stack.hasTagCompound()) {
        stack.setTagCompound(new NBTTagCompound());
    }
    NBTTagCompound tag = Objects.requireNonNull(stack.getTagCompound());
    tag.setTag("moduleInformation", nbt);
    if (module instanceof IClientInformationProvider) {
        List<String> information = ((IClientInformationProvider) module).getClientInformation();
        if (information.size() > 0) {
            NBTTagList list = new NBTTagList();
            for (String info : information) {
                list.appendTag(new NBTTagString(info));
            }
            tag.setTag("informationList", list);
        }
    }
    tag.setDouble("Random-Stack-Prevent", new Random().nextDouble());
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Random(java.util.Random) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString) IClientInformationProvider(logisticspipes.interfaces.IClientInformationProvider)

Aggregations

NBTTagString (net.minecraft.nbt.NBTTagString)101 NBTTagList (net.minecraft.nbt.NBTTagList)82 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)57 ItemStack (net.minecraft.item.ItemStack)18 NBTTagIntArray (net.minecraft.nbt.NBTTagIntArray)11 NBTBase (net.minecraft.nbt.NBTBase)10 NBTTagByteArray (net.minecraft.nbt.NBTTagByteArray)10 NBTTagInt (net.minecraft.nbt.NBTTagInt)10 NBTTagDouble (net.minecraft.nbt.NBTTagDouble)9 NBTTagFloat (net.minecraft.nbt.NBTTagFloat)9 NBTTagByte (net.minecraft.nbt.NBTTagByte)8 NBTTagLong (net.minecraft.nbt.NBTTagLong)8 ResourceLocation (net.minecraft.util.ResourceLocation)8 List (java.util.List)7 NBTTagShort (net.minecraft.nbt.NBTTagShort)7 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 Item (net.minecraft.item.Item)4