use of net.minecraft.nbt.NBTTagString in project ImmersiveEngineering by BluSunrize.
the class TileEntityTurret method writeCustomNBT.
@Override
public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) {
nbt.setBoolean("dummy", dummy);
nbt.setBoolean("redstoneInverted", redstoneControlInverted);
if (facing != null)
nbt.setInteger("facing", facing.ordinal());
energyStorage.writeToNBT(nbt);
if (owner != null)
nbt.setString("owner", owner);
NBTTagList list = new NBTTagList();
for (String s : targetList) list.appendTag(new NBTTagString(s));
nbt.setTag("targetList", list);
nbt.setBoolean("whitelist", whitelist);
nbt.setBoolean("attackAnimals", attackAnimals);
nbt.setBoolean("attackPlayers", attackPlayers);
nbt.setBoolean("attackNeutrals", attackNeutrals);
if (target != null)
nbt.setString("target", target.getUniqueID().toString());
}
use of net.minecraft.nbt.NBTTagString in project GregTech by GregTechCE.
the class TileEntitySurfaceRock method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
Material material = Material.MATERIAL_REGISTRY.getObject(compound.getString("Material"));
this.material = material == null ? Materials.Aluminium : material;
for (NBTBase undergroundMaterialNBTBase : compound.getTagList("UndergroundMaterials", NBT.TAG_STRING)) {
undergroundMaterials.add(Material.MATERIAL_REGISTRY.getObject(((NBTTagString) undergroundMaterialNBTBase).getString()));
}
}
use of net.minecraft.nbt.NBTTagString in project Almura by AlmuraDev.
the class LookingDebugPanel method renderEntity.
private void renderEntity(final Entity entity) {
final boolean player = entity instanceof EntityPlayer;
boolean drewItem = false;
ResourceLocation id;
if (player) {
id = EntityListAccessor.accessor$getPlayerResourceLocation();
} else {
id = EntityList.getKey(entity);
}
if (id != null) {
if (!player) {
// Draw egg, if available
if (EntityList.ENTITY_EGGS.containsKey(id)) {
final ItemStack item = new ItemStack(Items.SPAWN_EGG);
ItemMonsterPlacer.applyEntityIdToItemStack(item, id);
this.drawItem(item, 4, this.autoHeight + 4);
drewItem = true;
} else {
this.autoHeight += ITEM_HEIGHT_OFFSET;
}
} else {
// Draw the skull of the player
final ItemStack skull = new ItemStack(Items.SKULL, 1, 3);
final NBTTagCompound tag = new NBTTagCompound();
tag.setTag("SkullOwner", new NBTTagString(entity.getName()));
skull.setTagCompound(tag);
this.drawItem(skull, 4, this.autoHeight + 4);
drewItem = true;
}
this.drawText(Text.of(TextColors.WHITE, id.toString()), drewItem ? 24 : 4, this.autoHeight - 14, false, true);
this.autoHeight -= 2;
if (entity.hasCustomName() || player) {
this.drawProperty("name", entity.getName(), drewItem ? 24 : 4, this.autoHeight);
}
}
}
use of net.minecraft.nbt.NBTTagString in project Minechem by iopleke.
the class JournalItem method writeKnowledge.
/**
* Writes knowledge to the journal
*
* @param itemStack the journal stack
* @param player the player that writes the knowledge
* @param isRemote is the world remote on true it will send a {@link minechem.handler.message.JournalMessage} to the server
*/
public void writeKnowledge(ItemStack itemStack, EntityPlayer player, boolean isRemote) {
if (isRemote) {
MessageHandler.INSTANCE.sendToServer(new JournalMessage(player));
return;
}
NBTTagCompound tagCompound = itemStack.stackTagCompound;
Set<String> playerKnowledge = ResearchRegistry.getInstance().getResearchFor(player);
if (playerKnowledge == null) {
return;
}
Set<String> bookKnowledge = new LinkedHashSet<String>();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
} else if (tagCompound.hasKey("research")) {
NBTTagList bookKnowledgeTag = tagCompound.getTagList("research", 8);
for (int i = 0; i < bookKnowledgeTag.tagCount(); i++) {
bookKnowledge.add(bookKnowledgeTag.getStringTagAt(i));
}
}
bookKnowledge.addAll(playerKnowledge);
NBTTagList bookKnowledgeTag = new NBTTagList();
for (String knowledgeKey : bookKnowledge) {
bookKnowledgeTag.appendTag(new NBTTagString(knowledgeKey));
}
tagCompound.setTag("research", bookKnowledgeTag);
Set<String> authors = new LinkedHashSet<String>();
if (tagCompound.hasKey("authors")) {
NBTTagList authorsTag = tagCompound.getTagList("authors", 8);
for (int i = 0; i < authorsTag.tagCount(); i++) {
authors.add(authorsTag.getStringTagAt(i));
}
}
authors.add(player.getDisplayName());
NBTTagList authorsTag = new NBTTagList();
for (String author : authors) {
authorsTag.appendTag(new NBTTagString(author));
}
tagCompound.setTag("authors", authorsTag);
itemStack.setTagCompound(tagCompound);
}
use of net.minecraft.nbt.NBTTagString in project Minechem by iopleke.
the class AugmentedItem method setAugment.
/**
* Set {@link minechem.item.augment.augments.IAugment} on Item
*
* @param item ItemStack to add augment to
* @param augmentItem Augment to add
*/
@Override
public boolean setAugment(ItemStack item, ItemStack augmentItem) {
IAugment augment = AugmentRegistry.getAugment(augmentItem);
if (augment == null) {
return false;
}
if (!item.hasTagCompound()) {
item.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tagCompound = item.getTagCompound();
String augmentKey = augment.getKey();
if (!tagCompound.hasKey(augmentKey, Compendium.NBTTags.tagCompound)) {
NBTTagList augments = tagCompound.getTagList(augmentList, Compendium.NBTTags.tagString);
augments.appendTag(new NBTTagString(augmentKey));
tagCompound.setTag(augmentList, augments);
NBTTagCompound augmentTag = new NBTTagCompound();
augmentTag.setTag(Compendium.NBTTags.item, augmentItem.writeToNBT(new NBTTagCompound()));
augmentTag.setByte(this.level, (byte) 0);
tagCompound.setTag(augmentKey, augmentTag);
return true;
}
return false;
}
Aggregations