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;
}
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);
}
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();
}
}
}
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;
}
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());
}
Aggregations