use of net.minecraft.nbt.NBTTagString in project LogisticsPipes by RS485.
the class DebugHelper method addNBTToTree.
private void addNBTToTree(NBTBase nbt, DefaultMutableTreeNode node) throws SecurityException, IllegalArgumentException {
if (nbt == null) {
return;
}
if (nbt instanceof NBTTagByte) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagByte");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagByte) nbt).getByte()));
node.add(type);
} else if (nbt instanceof NBTTagByteArray) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagByteArray");
DefaultMutableTreeNode content = new DefaultMutableTreeNode("Data");
int i = 0;
for (byte byt : ((NBTTagByteArray) nbt).getByteArray()) {
content.add(new DefaultMutableTreeNode("[" + i + "]: " + byt));
i++;
}
node.add(content);
node.add(type);
} else if (nbt instanceof NBTTagDouble) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagDouble");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagDouble) nbt).getDouble()));
node.add(type);
} else if (nbt instanceof NBTTagFloat) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagFloat");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagFloat) nbt).getFloat()));
node.add(type);
} else if (nbt instanceof NBTTagInt) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagInt");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagInt) nbt).getInt()));
node.add(type);
} else if (nbt instanceof NBTTagIntArray) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagIntArray");
DefaultMutableTreeNode content = new DefaultMutableTreeNode("Data");
int i = 0;
for (int byt : ((NBTTagIntArray) nbt).getIntArray()) {
content.add(new DefaultMutableTreeNode("[" + i + "]: " + byt));
i++;
}
type.add(content);
node.add(type);
} else if (nbt instanceof NBTTagList) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagList");
DefaultMutableTreeNode content = new DefaultMutableTreeNode("Data");
int i = 0;
for (NBTBase object : (NBTTagList) nbt) {
DefaultMutableTreeNode nbtNode = new DefaultMutableTreeNode("[" + i + "]");
addNBTToTree(object, nbtNode);
content.add(nbtNode);
i++;
}
type.add(content);
node.add(type);
} else if (nbt instanceof NBTTagCompound) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagCompound");
DefaultMutableTreeNode content = new DefaultMutableTreeNode("Data");
for (String key : ((NBTTagCompound) nbt).getKeySet()) {
NBTBase value = ((NBTTagCompound) nbt).getTag(key);
DefaultMutableTreeNode nbtNode = new DefaultMutableTreeNode(key);
addNBTToTree(value, nbtNode);
content.add(nbtNode);
}
type.add(content);
node.add(type);
} else if (nbt instanceof NBTTagLong) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagLong");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagLong) nbt).getLong()));
node.add(type);
} else if (nbt instanceof NBTTagShort) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagShort");
type.add(new DefaultMutableTreeNode("Data: " + ((NBTTagShort) nbt).getShort()));
node.add(type);
} else if (nbt instanceof NBTTagString) {
DefaultMutableTreeNode type = new DefaultMutableTreeNode("NBTTagString");
type.add(new DefaultMutableTreeNode("Data: '" + ((NBTTagString) nbt).getString() + "'"));
node.add(type);
} else {
throw new UnsupportedOperationException("Unsupported NBTBase of type:" + nbt.getClass().getName());
}
}
use of net.minecraft.nbt.NBTTagString in project LogisticsPipes by RS485.
the class GuiProgramCompiler method drawGuiContainerBackgroundLayer.
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop, right, bottom, zLevel, true);
GuiGraphics.drawPlayerInventoryBackground(mc, guiLeft + 10, guiTop + 105);
GuiGraphics.drawSlotDiskBackground(mc, guiLeft + 9, guiTop + 9);
GuiGraphics.drawSlotProgrammerBackground(mc, guiLeft + 153, guiTop + 9);
if (compiler.getCurrentTask() != null) {
fontRenderer.drawString(TextUtil.translate("gui.compiler.processing"), guiLeft + 10, guiTop + 39, 0x000000);
String name;
Item item = Item.REGISTRY.getObject(compiler.getCurrentTask());
if (item != null) {
name = item.getUnlocalizedName() + ".name";
} else {
name = "gui.compiler." + compiler.getCurrentTask().toString().replace(':', '.');
}
String text = TextUtil.getTrimmedString(TextUtil.translate(name), 160, fontRenderer, "...");
fontRenderer.drawString(text, guiLeft + 10, guiTop + 70, 0x000000);
drawRect(guiLeft + 9, guiTop + 50, guiLeft + 171, guiTop + 66, Color.BLACK);
drawRect(guiLeft + 10, guiTop + 51, guiLeft + 170, guiTop + 65, Color.WHITE);
drawRect(guiLeft + 11, guiTop + 52, guiLeft + 11 + (int) (158 * compiler.getTaskProgress()), guiTop + 64, Color.GREEN);
if (!compiler.isWasAbleToConsumePower()) {
fontRenderer.drawString(TextUtil.translate("gui.compiler.nopower.1"), guiLeft + 68, guiTop + 10, 0x000000);
fontRenderer.drawString(TextUtil.translate("gui.compiler.nopower.2"), guiLeft + 35, guiTop + 20, 0x000000);
}
buttonList.forEach(b -> b.visible = false);
} else {
buttonList.forEach(b -> b.visible = true);
if (categoryTextList.getSize() == 0 && programTextList.getSize() != 0) {
buttonList.stream().limit(3).forEach(b -> b.visible = false);
programListLarge.renderGuiBackground(var2, var3);
} else {
buttonList.stream().limit(3).forEach(b -> b.visible = true);
categoryList.renderGuiBackground(var2, var3);
programList.renderGuiBackground(var2, var3);
}
search.drawTextBox();
int selIndex = programList.getSelected();
if (categoryTextList.getSize() == 0 && programTextList.getSize() != 0) {
selIndex = programListLarge.getSelected();
}
if (selIndex != -1) {
NBTTagList list = compiler.getNBTTagListForKey("compilerCategories");
ResourceLocation sel = getProgramListForSelectionIndex(list).get(selIndex);
NBTTagList listProgramms = compiler.getNBTTagListForKey("compilerPrograms");
if (StreamSupport.stream(listProgramms.spliterator(), false).anyMatch(it -> new ResourceLocation(((NBTTagString) it).getString()).equals(sel))) {
programmerButton.displayString = "Flash";
programmerButton.enabled = !compiler.getInventory().getStackInSlot(1).isEmpty();
} else {
programmerButton.displayString = "Compile";
programmerButton.enabled = true;
}
}
}
}
use of net.minecraft.nbt.NBTTagString in project LogisticsPipes by RS485.
the class GuiProgramCompiler method actionPerformed.
@Override
protected void actionPerformed(GuiButton button) throws IOException {
super.actionPerformed(button);
switch(button.id) {
case 0:
categoryList.scrollDown();
break;
case 1:
categoryList.scrollUp();
break;
case 2:
if (categoryList.getSelected() != -1) {
NBTTagList list = compiler.getNBTTagListForKey("compilerCategories");
LogisticsProgramCompilerTileEntity.programByCategory.keySet().stream().filter(it -> StreamSupport.stream(list.spliterator(), false).noneMatch(nbtBase -> ((NBTTagString) nbtBase).getString().equals(it.toString()))).skip(categoryList.getSelected()).findFirst().ifPresent(it -> {
MainProxy.sendPacketToServer(PacketHandler.getPacket(CompilerTriggerTaskPacket.class).setCategory(it).setType("category").setTilePos(compiler));
});
}
break;
case 3:
if (categoryTextList.getSize() == 0 && programTextList.getSize() != 0) {
programListLarge.scrollDown();
} else {
programList.scrollDown();
}
break;
case 4:
if (categoryTextList.getSize() == 0 && programTextList.getSize() != 0) {
programListLarge.scrollUp();
} else {
programList.scrollUp();
}
break;
case 5:
int selIndex = programList.getSelected();
if (categoryTextList.getSize() == 0 && programTextList.getSize() != 0) {
selIndex = programListLarge.getSelected();
}
if (selIndex != -1) {
NBTTagList list = compiler.getNBTTagListForKey("compilerCategories");
ResourceLocation sel = getProgramListForSelectionIndex(list).get(selIndex);
NBTTagList listPrograms = compiler.getNBTTagListForKey("compilerPrograms");
boolean flag = StreamSupport.stream(listPrograms.spliterator(), false).anyMatch(it -> new ResourceLocation(((NBTTagString) it).getString()).equals(sel));
MainProxy.sendPacketToServer(PacketHandler.getPacket(CompilerTriggerTaskPacket.class).setCategory(sel).setType(flag ? "flash" : "program").setTilePos(compiler));
}
break;
}
}
use of net.minecraft.nbt.NBTTagString in project LogisticsPipes by RS485.
the class LogisticsTileGenericSubMultiBlock method writeToNBT.
@Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
nbt = super.writeToNBT(nbt);
NBTTagList nbtList = new NBTTagList();
for (DoubleCoordinates pos : mainPipePos) {
NBTTagCompound compound = new NBTTagCompound();
pos.writeToNBT("MainPipePos_", compound);
nbtList.appendTag(compound);
}
nbt.setTag("MainPipePosList", nbtList);
NBTTagList nbtTypeList = new NBTTagList();
for (CoreMultiBlockPipe.SubBlockTypeForShare type : subTypes) {
if (type == null)
continue;
nbtTypeList.appendTag(new NBTTagString(type.name()));
}
nbt.setTag("SubTypeList", nbtTypeList);
return nbt;
}
use of net.minecraft.nbt.NBTTagString in project ImmersiveEngineering by BluSunrize.
the class ItemNBTHelper method setLore.
public static void setLore(ItemStack stack, String... lore) {
NBTTagCompound displayTag = getTagCompound(stack, "display");
NBTTagList list = new NBTTagList();
for (String s : lore) list.appendTag(new NBTTagString(s));
displayTag.setTag("Lore", list);
setTagCompound(stack, "display", displayTag);
}
Aggregations