use of net.minecraft.nbt.NBTTagString 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.NBTTagString in project Railcraft by Railcraft.
the class ItemPost method addInformation.
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> info, boolean adv) {
if (stack.getItemDamage() == EnumPost.EMBLEM.ordinal() && stack.hasTagCompound()) {
NBTTagCompound nbt = stack.getTagCompound();
NBTTagString emblemIdent = (NBTTagString) nbt.getTag("emblem");
if (emblemIdent == null || EmblemToolsClient.packageManager == null)
return;
Emblem emblem = EmblemToolsClient.packageManager.getEmblem(emblemIdent.getString());
if (emblem != null)
info.add(TextFormatting.GRAY + emblem.displayName);
}
}
use of net.minecraft.nbt.NBTTagString in project ArsMagica2 by Mithion.
the class BlockManaBattery method destroy.
private void destroy(World world, int i, int j, int k) {
TileEntityManaBattery te = getTileEntity(world, i, j, k);
if (te != null && !world.isRemote) {
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
int dmg = (int) ((PowerNodeRegistry.For(world).getPower(te, te.getPowerType()) / te.getCapacity()) * 100);
if (dmg == 0)
dmg = 1;
ItemStack stack = new ItemStack(this);
stack.damageItem(stack.getMaxDamage() - dmg, new EntityDummyCaster(world));
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setFloat("mana_battery_charge", PowerNodeRegistry.For(world).getPower(te, te.getPowerType()));
stack.stackTagCompound.setInteger("mana_battery_powertype", te.getPowerType().ID());
if (!stack.stackTagCompound.hasKey("Lore"))
stack.stackTagCompound.setTag("Lore", new NBTTagList());
NBTTagList tagList = new NBTTagList();
PowerTypes powerType = te.getPowerType();
float amt = PowerNodeRegistry.For(world).getPower(te, powerType);
tagList.appendTag(new NBTTagString(String.format("Contains %.2f %s%s etherium", amt, powerType.chatColor(), powerType.name())));
stack.stackTagCompound.setTag("Lore", tagList);
EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, stack);
float f3 = 0.05F;
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
use of net.minecraft.nbt.NBTTagString in project Totemic by TeamTotemic.
the class StateSelection method writeToNBT.
@Override
void writeToNBT(NBTTagCompound tag) {
NBTTagList selectorsTag = new NBTTagList();
for (MusicInstrument instr : selectors) selectorsTag.appendTag(new NBTTagString(instr.getRegistryName().toString()));
tag.setTag("selectors", selectorsTag);
}
use of net.minecraft.nbt.NBTTagString in project Totemic by TeamTotemic.
the class CamelCaseNamesTiles method fixTagCompound.
@Override
public NBTTagCompound fixTagCompound(NBTTagCompound compound) {
switch(compound.getString("id")) {
case "totemic:totem_base":
int state = compound.getByte("state");
switch(state) {
case // StateSelection
1:
NBTTagList selectorsTag = compound.getTagList("selectors", 8);
for (int i = 0; i < selectorsTag.tagCount(); i++) {
String name = checkAndFixName(selectorsTag.getStringTagAt(i), "Music Instrument");
selectorsTag.set(i, new NBTTagString(name));
}
break;
case // StateStartup
2:
String ceremonyName = compound.getString("ceremony");
compound.setString("ceremony", checkAndFixName(ceremonyName, "Ceremony"));
NBTTagCompound ceremonyMusic = compound.getCompoundTag("ceremonyMusic");
compound.setTag("ceremonyMusic", fixCompoundKeys(ceremonyMusic, "Music Instrument"));
NBTTagCompound timesPlayed = compound.getCompoundTag("timesPlayed");
compound.setTag("timesPlayed", fixCompoundKeys(timesPlayed, "Music Instrument"));
break;
case // StateCeremonyEffect
3:
ceremonyName = compound.getString("ceremony");
compound.setString("ceremony", checkAndFixName(ceremonyName, "Ceremony"));
break;
}
break;
case "totemic:totem_pole":
if (compound.hasKey("effect", Constants.NBT.TAG_STRING)) {
String name = compound.getString("effect");
compound.setString("effect", checkAndFixName(name, "Totem Effect"));
}
break;
}
return compound;
}
Aggregations