use of net.minecraft.nbt.NBTTagList in project LogisticsPipes by RS485.
the class GuiAddMacro method loadMacroItems.
private void loadMacroItems() {
if ((name1 + name2).equals("")) {
return;
}
NBTTagList inventar = null;
NBTTagList list = diskProvider.getDisk().getTagCompound().getTagList("macroList", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound tag = list.getCompoundTagAt(i);
String name = tag.getString("name");
if (name.equals(name1 + name2)) {
inventar = tag.getTagList("inventar", 10);
break;
}
}
if (inventar == null) {
return;
}
for (int i = 0; i < inventar.tagCount(); i++) {
NBTTagCompound itemNBT = inventar.getCompoundTagAt(i);
int itemID = itemNBT.getInteger("id");
int itemData = itemNBT.getInteger("data");
NBTTagCompound tag = null;
if (itemNBT.hasKey("nbt")) {
tag = itemNBT.getCompoundTag("nbt");
}
ItemIdentifier item = ItemIdentifier.get(Item.getItemById(itemID), itemData, tag);
int amount = itemNBT.getInteger("amount");
ItemIdentifierStack stack = new ItemIdentifierStack(item, amount);
macroItems.add(stack);
}
}
use of net.minecraft.nbt.NBTTagList in project LogisticsPipes by RS485.
the class GuiDiskPopup method renderGuiBackground.
@Override
protected void renderGuiBackground(int par1, int par2) {
GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop, right, bottom, zLevel, true);
mc.fontRenderer.drawStringWithShadow("Disk", xCenter - (mc.fontRenderer.getStringWidth("Disk") / 2), guiTop + 10, 0xFFFFFF);
//NameInput
if (editname) {
Gui.drawRect(guiLeft + 10, guiTop + 28, right - 10, guiTop + 45, Color.getValue(Color.BLACK));
Gui.drawRect(guiLeft + 11, guiTop + 29, right - 11, guiTop + 44, Color.getValue(Color.WHITE));
} else {
Gui.drawRect(guiLeft + 11, guiTop + 29, right - 11, guiTop + 44, Color.getValue(Color.BLACK));
}
Gui.drawRect(guiLeft + 12, guiTop + 30, right - 12, guiTop + 43, Color.getValue(Color.DARKER_GREY));
mc.fontRenderer.drawString(name1 + name2, guiLeft + 15, guiTop + 33, 0xFFFFFF);
Gui.drawRect(guiLeft + 6, guiTop + 46, right - 6, bottom - 30, Color.getValue(Color.GREY));
NBTTagCompound nbt = diskProvider.getDisk().getTagCompound();
if (nbt == null) {
diskProvider.getDisk().setTagCompound(new NBTTagCompound());
nbt = diskProvider.getDisk().getTagCompound();
}
if (!nbt.hasKey("macroList")) {
NBTTagList list = new NBTTagList();
nbt.setTag("macroList", list);
}
NBTTagList list = nbt.getTagList("macroList", 10);
if (scroll + 12 > list.tagCount()) {
scroll = list.tagCount() - 12;
}
if (scroll < 0) {
scroll = 0;
}
boolean flag = false;
if (guiLeft + 8 < mouseX && mouseX < right - 8 && guiTop + 48 < mouseY && mouseY < guiTop + 59 + (11 * 10)) {
selected = scroll + (mouseY - guiTop - 49) / 10;
}
for (int i = scroll; i < list.tagCount() && (i - scroll) < 12; i++) {
if (i == selected) {
Gui.drawRect(guiLeft + 8, guiTop + 48 + ((i - scroll) * 10), right - 8, guiTop + 59 + ((i - scroll) * 10), Color.getValue(Color.DARKER_GREY));
flag = true;
}
NBTTagCompound entry = list.getCompoundTagAt(i);
String name = entry.getString("name");
mc.fontRenderer.drawString(name, guiLeft + 10, guiTop + 50 + ((i - scroll) * 10), 0xFFFFFF);
}
if (!flag) {
selected = -1;
}
if (editname) {
int linex = guiLeft + 15 + mc.fontRenderer.getStringWidth(name1);
if (System.currentTimeMillis() - oldSystemTime > 500) {
displaycursor = !displaycursor;
oldSystemTime = System.currentTimeMillis();
}
if (displaycursor) {
Gui.drawRect(linex, guiTop + 31, linex + 1, guiTop + 42, Color.getValue(Color.WHITE));
}
}
}
use of net.minecraft.nbt.NBTTagList in project LogisticsPipes by RS485.
the class ModuleCrafter method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
// super.writeToNBT(nbttagcompound);
_dummyInventory.writeToNBT(nbttagcompound, "");
_liquidInventory.writeToNBT(nbttagcompound, "FluidInv");
_cleanupInventory.writeToNBT(nbttagcompound, "CleanupInv");
nbttagcompound.setInteger("satelliteid", satelliteId);
nbttagcompound.setInteger("priority", priority);
for (int i = 0; i < 9; i++) {
nbttagcompound.setInteger("advancedSatelliteId" + i, advancedSatelliteIdArray[i]);
}
NBTTagList lst = new NBTTagList();
for (int i = 0; i < 9; i++) {
NBTTagCompound comp = new NBTTagCompound();
comp.setBoolean("ignore_dmg", fuzzyCraftingFlagArray[i].ignore_dmg);
comp.setBoolean("ignore_nbt", fuzzyCraftingFlagArray[i].ignore_nbt);
comp.setBoolean("use_od", fuzzyCraftingFlagArray[i].use_od);
comp.setBoolean("use_category", fuzzyCraftingFlagArray[i].use_category);
lst.appendTag(comp);
}
nbttagcompound.setTag("fuzzyFlags", lst);
{
NBTTagCompound comp = new NBTTagCompound();
comp.setBoolean("ignore_dmg", outputFuzzyFlags.ignore_dmg);
comp.setBoolean("ignore_nbt", outputFuzzyFlags.ignore_nbt);
comp.setBoolean("use_od", outputFuzzyFlags.use_od);
comp.setBoolean("use_category", outputFuzzyFlags.use_category);
nbttagcompound.setTag("outputFuzzyFlags", comp);
}
for (int i = 0; i < 6; i++) {
nbttagcompound.setBoolean("craftingSigns" + i, craftingSigns[i]);
}
for (int i = 0; i < ItemUpgrade.MAX_LIQUID_CRAFTER; i++) {
nbttagcompound.setInteger("liquidSatelliteIdArray" + i, liquidSatelliteIdArray[i]);
}
nbttagcompound.setIntArray("FluidAmount", amount);
nbttagcompound.setInteger("liquidSatelliteId", liquidSatelliteId);
nbttagcompound.setBoolean("cleanupModeIsExclude", cleanupModeIsExclude);
}
use of net.minecraft.nbt.NBTTagList in project LogisticsPipes by RS485.
the class ItemModule method addInformation.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean flag) {
if (itemStack.hasTagCompound()) {
NBTTagCompound nbt = itemStack.getTagCompound();
if (nbt.hasKey("informationList")) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
NBTTagList nbttaglist = nbt.getTagList("informationList", 8);
for (int i = 0; i < nbttaglist.tagCount(); i++) {
Object nbttag = nbttaglist.tagList.get(i);
String data = ((NBTTagString) nbttag).func_150285_a_();
if (data.equals("<inventory>") && i + 1 < nbttaglist.tagCount()) {
nbttag = nbttaglist.tagList.get(i + 1);
data = ((NBTTagString) nbttag).func_150285_a_();
if (data.startsWith("<that>")) {
String prefix = data.substring(6);
NBTTagCompound module = nbt.getCompoundTag("moduleInformation");
int size = module.getTagList(prefix + "items", module.getId()).tagCount();
if (module.hasKey(prefix + "itemsCount")) {
size = module.getInteger(prefix + "itemsCount");
}
ItemIdentifierInventory inv = new ItemIdentifierInventory(size, "InformationTempInventory", Integer.MAX_VALUE);
inv.readFromNBT(module, prefix);
for (int pos = 0; pos < inv.getSizeInventory(); pos++) {
ItemIdentifierStack stack = inv.getIDStackInSlot(pos);
if (stack != null) {
if (stack.getStackSize() > 1) {
list.add(" " + stack.getStackSize() + "x " + stack.getFriendlyName());
} else {
list.add(" " + stack.getFriendlyName());
}
}
}
}
i++;
} else {
list.add(data);
}
}
} else {
list.add(StringUtils.translate(StringUtils.KEY_HOLDSHIFT));
}
} else {
StringUtils.addShiftAddition(itemStack, list);
}
} else {
StringUtils.addShiftAddition(itemStack, list);
}
}
use of net.minecraft.nbt.NBTTagList in project LogisticsPipes by RS485.
the class CoreRoutedPipe method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
synchronized (routerIdLock) {
routerId = nbttagcompound.getString("routerId");
}
stat_lifetime_sent = nbttagcompound.getLong("stat_lifetime_sent");
stat_lifetime_recieved = nbttagcompound.getLong("stat_lifetime_recieved");
stat_lifetime_relayed = nbttagcompound.getLong("stat_lifetime_relayed");
if (getLogisticsModule() != null) {
getLogisticsModule().readFromNBT(nbttagcompound);
}
upgradeManager.readFromNBT(nbttagcompound.getCompoundTag("upgradeManager"));
powerHandler.readFromNBT(nbttagcompound.getCompoundTag("powerHandler"));
_sendQueue.clear();
NBTTagList sendqueue = nbttagcompound.getTagList("sendqueue", nbttagcompound.getId());
for (int i = 0; i < sendqueue.tagCount(); i++) {
NBTTagCompound tagentry = sendqueue.getCompoundTagAt(i);
NBTTagCompound tagentityitem = tagentry.getCompoundTag("entityitem");
LPTravelingItemServer item = new LPTravelingItemServer(tagentityitem);
ForgeDirection from = ForgeDirection.values()[tagentry.getByte("from")];
ItemSendMode mode = ItemSendMode.values()[tagentry.getByte("mode")];
_sendQueue.add(new Triplet<>(item, from, mode));
}
for (int i = 0; i < 6; i++) {
if (nbttagcompound.getBoolean("PipeSign_" + i)) {
int type = nbttagcompound.getInteger("PipeSign_" + i + "_type");
Class<? extends IPipeSign> typeClass = ItemPipeSignCreator.signTypes.get(type);
try {
signItem[i] = typeClass.newInstance();
signItem[i].init(this, ForgeDirection.getOrientation(i));
signItem[i].readFromNBT(nbttagcompound.getCompoundTag("PipeSign_" + i + "_tags"));
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
}
Aggregations