use of am2.utility.KeyValuePair in project ArsMagica2 by Mithion.
the class TileEntityCraftingAltar method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
if (!nbttagcompound.hasKey("altarData"))
return;
NBTTagCompound altarCompound = nbttagcompound.getCompoundTag("altarData");
NBTTagList allAddedItems = altarCompound.getTagList("allAddedItems", Constants.NBT.TAG_COMPOUND);
NBTTagList currentAddedItems = altarCompound.getTagList("currentAddedItems", Constants.NBT.TAG_COMPOUND);
this.isCrafting = altarCompound.getBoolean("isCrafting");
this.currentKey = altarCompound.getInteger("currentKey");
this.currentSpellName = altarCompound.getString("currentSpellName");
if (altarCompound.hasKey("phylactery")) {
NBTTagCompound phylactery = altarCompound.getCompoundTag("phylactery");
if (phylactery != null)
this.addedPhylactery = ItemStack.loadItemStackFromNBT(phylactery);
}
if (altarCompound.hasKey("catalyst")) {
NBTTagCompound catalyst = altarCompound.getCompoundTag("catalyst");
if (catalyst != null)
this.addedBindingCatalyst = ItemStack.loadItemStackFromNBT(catalyst);
}
this.allAddedItems.clear();
for (int i = 0; i < allAddedItems.tagCount(); ++i) {
NBTTagCompound addedItem = (NBTTagCompound) allAddedItems.getCompoundTagAt(i);
if (addedItem == null)
continue;
ItemStack stack = ItemStack.loadItemStackFromNBT(addedItem);
if (stack == null)
continue;
this.allAddedItems.add(stack);
}
this.currentAddedItems.clear();
for (int i = 0; i < currentAddedItems.tagCount(); ++i) {
NBTTagCompound addedItem = (NBTTagCompound) currentAddedItems.getCompoundTagAt(i);
if (addedItem == null)
continue;
ItemStack stack = ItemStack.loadItemStackFromNBT(addedItem);
if (stack == null)
continue;
this.currentAddedItems.add(stack);
}
this.spellDef.clear();
for (ArrayList<KeyValuePair<ISpellPart, byte[]>> groups : shapeGroups) groups.clear();
NBTTagCompound currentSpellDef = altarCompound.getCompoundTag("spellDef");
this.spellDef.addAll(NBTToISpellPartList(currentSpellDef));
NBTTagList currentShapeGroups = altarCompound.getTagList("shapeGroups", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < currentShapeGroups.tagCount(); ++i) {
NBTTagCompound compound = (NBTTagCompound) currentShapeGroups.getCompoundTagAt(i);
shapeGroups.get(i).addAll(NBTToISpellPartList(compound));
}
}
use of am2.utility.KeyValuePair in project ArsMagica2 by Mithion.
the class TileEntityCraftingAltar method NBTToISpellPartList.
private ArrayList<KeyValuePair<ISpellPart, byte[]>> NBTToISpellPartList(NBTTagCompound compound) {
int[] ids = compound.getIntArray("group_ids");
ArrayList<KeyValuePair<ISpellPart, byte[]>> list = new ArrayList<KeyValuePair<ISpellPart, byte[]>>();
for (int i = 0; i < ids.length; ++i) {
int partID = ids[i];
ISkillTreeEntry part = SkillManager.instance.getSkill(i);
byte[] partMeta = compound.getByteArray("meta_" + i);
if (part instanceof ISpellPart) {
list.add(new KeyValuePair<ISpellPart, byte[]>((ISpellPart) part, partMeta));
}
}
return list;
}
use of am2.utility.KeyValuePair in project ArsMagica2 by Mithion.
the class TileEntityCraftingAltar method setCrafting.
private void setCrafting(boolean crafting) {
this.isCrafting = crafting;
if (!worldObj.isRemote) {
AMDataWriter writer = new AMDataWriter();
writer.add(xCoord);
writer.add(yCoord);
writer.add(zCoord);
writer.add(CRAFTING_CHANGED);
writer.add(crafting);
AMNetHandler.INSTANCE.sendPacketToAllClientsNear(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 32, AMPacketIDs.CRAFTING_ALTAR_DATA, writer.generate());
}
if (crafting) {
allAddedItems.clear();
currentAddedItems.clear();
spellDef.clear();
for (ArrayList<KeyValuePair<ISpellPart, byte[]>> groups : shapeGroups) groups.clear();
//find otherworld auras
IPowerNode[] nodes = PowerNodeRegistry.For(worldObj).getAllNearbyNodes(worldObj, new AMVector3(this), PowerTypes.DARK);
for (IPowerNode node : nodes) {
if (node instanceof TileEntityOtherworldAura) {
((TileEntityOtherworldAura) node).setActive(true, this);
break;
}
}
}
}
Aggregations