Java Code Examples for net.minecraft.nbt.NBTTagCompound#setString()

The following examples show how to use net.minecraft.nbt.NBTTagCompound#setString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CraftMetaPotion.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@Override
void applyToItem(NBTTagCompound tag) {
    super.applyToItem(tag);

    tag.setString(DEFAULT_POTION.NBT, (this.type.getType() == PotionType.UNCRAFTABLE && emptyType != null) ? emptyType : CraftPotionUtil.fromBukkit(type));

    if (hasColor()) {
        tag.setInteger(POTION_COLOR.NBT, color.asRGB());
    }

    if (customEffects != null) {
        NBTTagList effectList = new NBTTagList();
        tag.setTag(POTION_EFFECTS.NBT, effectList);

        for (PotionEffect effect : customEffects) {
            NBTTagCompound effectData = new NBTTagCompound();
            effectData.setByte(ID.NBT, (byte) effect.getType().getId());
            effectData.setByte(AMPLIFIER.NBT, (byte) effect.getAmplifier());
            effectData.setInteger(DURATION.NBT, effect.getDuration());
            effectData.setBoolean(AMBIENT.NBT, effect.isAmbient());
            effectData.setBoolean(SHOW_PARTICLES.NBT, effect.hasParticles());
            effectList.appendTag(effectData);
        }
    }
}
 
Example 2
Source File: TileEntitySaltFurnace.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound par1NBTTagCompound) {
    super.writeToNBT(par1NBTTagCompound);
    par1NBTTagCompound.setShort("BurnTime", (short) this.furnaceBurnTime);
    par1NBTTagCompound.setShort("CookTime", (short) this.cookTime);
    par1NBTTagCompound.setInteger("ItemBurnTime", this.currentItemBurnTime);

    NBTTagCompound nigariTag = this.nigariTank.writeToNBT(new NBTTagCompound());
    par1NBTTagCompound.setTag("NigariTank", nigariTag);

    ItemStackHelper.saveAllItems(par1NBTTagCompound, this.furnaceItemStacks);

    if (this.hasCustomName()) {
        par1NBTTagCompound.setString("CustomName", this.customName);
    }

    return par1NBTTagCompound;
}
 
Example 3
Source File: SemiBlockManager.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onChunkSave(ChunkDataEvent.Save event){
    Map<ChunkPosition, ISemiBlock> map = semiBlocks.get(event.getChunk());
    if(map != null && map.size() > 0) {
        NBTTagList tagList = new NBTTagList();
        for(Map.Entry<ChunkPosition, ISemiBlock> entry : map.entrySet()) {
            NBTTagCompound t = new NBTTagCompound();
            entry.getValue().writeToNBT(t);
            t.setInteger("x", entry.getKey().chunkPosX);
            t.setInteger("y", entry.getKey().chunkPosY);
            t.setInteger("z", entry.getKey().chunkPosZ);
            t.setString("type", getKeyForSemiBlock(entry.getValue()));
            tagList.appendTag(t);
        }
        event.getData().setTag("SemiBlocks", tagList);
    }
}
 
Example 4
Source File: TileEntityDisplayPedestal.java    From Artifacts with MIT License 6 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound tag)
{
	super.writeToNBT(tag);
	NBTTagList nbttaglist = new NBTTagList();

	if (this.contents != null)
	{
		NBTTagCompound nbttagcompound1 = new NBTTagCompound();
		nbttagcompound1.setByte("Slot", (byte) 0);
		this.contents.writeToNBT(nbttagcompound1);
		nbttaglist.appendTag(nbttagcompound1);
	}

	tag.setTag("Items", nbttaglist);
	tag.setString("OwnerName", ownerName);
	tag.setLong("OwnerUUIDLeast", ownerUUID.getLeastSignificantBits());
	tag.setLong("OwnerUUIDMost", ownerUUID.getMostSignificantBits());
	tag.setInteger("rotation", rotation);
}
 
Example 5
Source File: TofuCastlePiece.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
protected void writeStructureToNBT(NBTTagCompound compound) {
    super.writeStructureToNBT(compound);
    compound.setBoolean("BossRoom", this.isAleadyBossRoomGen);
    compound.setString("Template", this.templateName);
    compound.setString("Rot", this.placeSettings.getRotation().name());
    compound.setString("Mi", this.placeSettings.getMirror().name());
}
 
Example 6
Source File: LingerBrain.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound nbt)
{
	nbt.setInteger("activityTimer", activityTimer);

	NBTTagCompound goalNBT = new NBTTagCompound();
	currentGoal.writeToNBT(goalNBT);
	nbt.setTag("currentGoal", goalNBT);

	nbt.setInteger("currentLocation", currentLocation.index);
	nbt.setString("currentActivity", currentActivity.getName());
}
 
Example 7
Source File: ItemJournal.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
public void addEntry(@Nonnull ItemStack journal, @Nullable IAgriPlant plant) {
    // Validate.
    Preconditions.checkNotNull(journal);
    // Do stuff.
    if (plant != null) {
        if (!isSeedDiscovered(journal, plant)) {
            NBTTagCompound tag = StackHelper.getTag(journal);
            String old = tag.getString(AgriNBT.DISCOVERED_SEEDS);
            tag.setString(AgriNBT.DISCOVERED_SEEDS, old + plant.getId() + ";");
            journal.setTagCompound(tag);
        }
    }
}
 
Example 8
Source File: FWEntity.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void writeEntityToNBT(NBTTagCompound nbt) {
	if (wrapped instanceof Storable) {
		Data data = new Data();
		((Storable) wrapped).save(data);
		nbt.setTag("nova", DataConverter.instance().toNative(data));
	}
	nbt.setString("novaID", wrapped.getID());
}
 
Example 9
Source File: Squashable.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public NBTTagCompound serializeNBT() {
    NBTTagCompound compound = new NBTTagCompound();
    if (this.squashedAxis != null) {
        compound.setString("squashed_axis", this.squashedAxis.getName());
    }
    return compound;
}
 
Example 10
Source File: SellSign.java    From MyTown2 with The Unlicense 5 votes vote down vote up
public SellSign(BlockPos bp, int face, Resident owner, int price, boolean restricted) {
    super(SellSignType.instance);
    this.bp = bp;
    this.price = price;
    this.restricted = restricted;
    this.plot = MyTownUniverse.instance.plots.get(bp.getDim(), bp.getX(), bp.getY(), bp.getZ());
    this.owner = owner;
    NBTTagCompound data = new NBTTagCompound();
    data.setString("Owner", owner.getUUID().toString());
    data.setInteger("Price", price);
    data.setBoolean("Restricted", restricted);
    this.data = data;
    createSignBlock(owner.getPlayer(), bp, face);
}
 
Example 11
Source File: FluidStorageInventoryHandler.java    From ExtraCells1 with MIT License 5 votes vote down vote up
private void writeNameToNBT(String name)
{
	if (storage.stackTagCompound == null)
		storage.stackTagCompound = new NBTTagCompound();
	NBTTagCompound nbt = storage.stackTagCompound;

	nbt.setString("PreformattedName", name);
}
 
Example 12
Source File: ActionWidgetCheckBox.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public NBTTagCompound toNBT(int guiLeft, int guiTop){
    NBTTagCompound tag = super.toNBT(guiLeft, guiTop);
    tag.setInteger("x", widget.x - guiLeft);
    tag.setInteger("y", widget.y - guiTop);
    tag.setString("text", widget.text);
    tag.setString("tooltip", widget.getTooltip());
    return tag;
}
 
Example 13
Source File: AspectList.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
/**
 * Writes the list of aspects to nbt
 * @param nbttagcompound
 * @return 
 */
public void writeToNBT(NBTTagCompound nbttagcompound)
   {
       NBTTagList tlist = new NBTTagList();
	nbttagcompound.setTag("Aspects", tlist);
	for (Aspect aspect : getAspects())
		if (aspect != null) {
			NBTTagCompound f = new NBTTagCompound();
			f.setString("key", aspect.getTag());
			f.setInteger("amount", getAmount(aspect));
			tlist.appendTag(f);
		}
   }
 
Example 14
Source File: SatelliteProperties.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void writeToNBT(NBTTagCompound nbt) {
	nbt.setInteger("powerGeneration", powerGeneration);
	nbt.setInteger("powerStorage", powerStorage);
	nbt.setString("dataType", satType);
	nbt.setLong("satId", id);
	nbt.setInteger("maxData", maxData);
}
 
Example 15
Source File: PythonCode.java    From pycode-minecraft with MIT License 4 votes vote down vote up
public void writeToNBT(NBTTagCompound compound) {
    compound.setString(CODE_NBT_TAG, this.code);
}
 
Example 16
Source File: TileEntityStationMarker.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound){
    super.writeToNBT(compound);
    compound.setString("stationName", stationName);
    return compound;
}
 
Example 17
Source File: MoCTools.java    From mocreaturesdev with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Drops an amulet with the stored information of the entity passed
 * @param entity
 */
public static void dropAmulet(MoCEntityAnimal entity)
{
    if (MoCreatures.isServer())
    {
           ItemStack stack = getProperAmulet(entity);
            if (stack == null) 
            {
            	return;
            }
        	if( stack.stackTagCompound == null )
    		{
            	stack.setTagCompound(new NBTTagCompound());
    		}
    		NBTTagCompound nbtt = stack.stackTagCompound;
    		
            try
            {
            	//TODO change the 21 to the list given based on the class of the creature
            	nbtt.setInteger("SpawnClass", 21); //21 is the spawnlist number for horses //TODO change to a list
            	nbtt.setInteger("Health", entity.getHealth());
        		nbtt.setInteger("Edad", entity.getEdad());
        		nbtt.setString("Name", entity.getName());
        		nbtt.setBoolean("Rideable", entity.getIsRideable());
        		nbtt.setByte("Armor", entity.getArmorType());
        		nbtt.setInteger("CreatureType", entity.getType());
        		nbtt.setBoolean("Adult", entity.getIsAdult());          
        		nbtt.setString("OwnerName", entity.getOwnerName());
            }
            catch (Exception e)
            {
            }
            EntityItem entityitem = new EntityItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, stack);

            entityitem.delayBeforeCanPickup = 20;
            entity.worldObj.spawnEntityInWorld(entityitem);
        

        

    }
}
 
Example 18
Source File: PlayerCivilization.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
public static NBTTagCompound buildNBTReputationListItem(CivilizationType civ, int rep) {
	NBTTagCompound c = new NBTTagCompound();
	c.setString("civ", s(civ));
	c.setInteger("amount", rep);
	return c;
}
 
Example 19
Source File: InventoryUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static NBTTagCompound savePersistant(ItemStack stack, NBTTagCompound tag) {
    stack.writeToNBT(tag);
    tag.removeTag("id");
    tag.setString("name", Item.itemRegistry.getNameForObject(stack.getItem()).toString());
    return tag;
}
 
Example 20
Source File: VanillaStructure.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void writeMetadataToTag(NBTTagCompound tag)
{
    tag.setTag("Metadata", this.getMetadata().toTag());
    tag.setString("author", this.getMetadata().getAuthor());
}