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

The following examples show how to use net.minecraft.nbt.NBTTagCompound#setIntArray() . 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: RiverAttribute.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound nbt) 
{
	nbt.setString("uuid", id.toString());
	nbt.setDouble("river", river);
	if(downriver != null)
		nbt.setInteger("downriver", downriver.index);

	if(upriver != null && upriver.size() > 0)
	{
		int[] nArray = new int[upriver.size()];
		for(int i = 0; i < nArray.length; i++)
		{
			nArray[i] = upriver.get(i).index;
		}
		nbt.setIntArray("upriver", nArray);
	}

	nbt.setDouble("midX", riverMid.x);
	nbt.setDouble("midY", riverMid.y);
	nbt.setBoolean("isDead", deadRiver);
}
 
Example 2
Source File: GTItemSensorStick.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX,
		float hitY, float hitZ, EnumHand hand) {
	if (IC2.platform.isRendering()) {
		IC2.audioManager.playOnce(player, Ic2Sounds.wrenchUse);
		return EnumActionResult.SUCCESS;
	}
	TileEntity tileEntity = world.getTileEntity(pos);
	if (tileEntity instanceof IGTCoordinateTile) {
		return tryParseCoords((IGTCoordinateTile) tileEntity, world, player, hand);
	} else {
		NBTTagCompound nbt = StackUtil.getOrCreateNbtData(player.getHeldItem(hand));
		nbt.setIntArray(POS, new int[] { pos.getX(), pos.getY(), pos.getZ(), world.provider.getDimension() });
		String blockName = world.getBlockState(pos).getBlock().getLocalizedName();
		nbt.setString(BLOCK, blockName);
		IC2.platform.messagePlayer(player, "Coordinates set to " + blockName);
	}
	return EnumActionResult.SUCCESS;
}
 
Example 3
Source File: TileLandingPad.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);

	if(!blockPos.isEmpty()) {
		int[] array = new int[blockPos.size()*3];
		int counter = 0;
		for(HashedBlockPosition pos : blockPos) {
			array[counter] = pos.x;
			array[counter+1] = pos.y;
			array[counter+2] = pos.z;
			counter += 3;
		}

		nbt.setIntArray("infrastructureLocations", array);
	}

	if(name != null && !name.isEmpty())
		nbt.setString("name", name);

	return nbt;
}
 
Example 4
Source File: TileEntityElevatorBase.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void writeToPacket(NBTTagCompound tag){
    super.writeToPacket(tag);
    tag.setIntArray("floorHeights", floorHeights);

    NBTTagList floorNameList = new NBTTagList();
    for(int key : floorNames.keySet()) {
        NBTTagCompound floorNameTag = new NBTTagCompound();
        floorNameTag.setInteger("floorHeight", key);
        floorNameTag.setString("floorName", floorNames.get(key));
        floorNameList.appendTag(floorNameTag);
    }
    tag.setTag("floorNames", floorNameList);
}
 
Example 5
Source File: Corner.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void writeToNBT(NBTTagCompound nbt)
{
	nbt.setInteger("index", index);
	nbt.setDouble("xCoord", point.x);
	nbt.setDouble("yCoord", point.y);
	int f = 0;
	for(Marker ff : flags)
	{
		f += ff.getFlag();
	}
	nbt.setInteger("flags", f);
	nbt.setDouble("elevation", elevation);
	nbt.setDouble("moisture", moisture);

	int[] nArray = new int[touches.size()];
	for(int i = 0; i < nArray.length; i++)
	{
		nArray[i] = touches.get(i).index;
	}
	nbt.setIntArray("touches", nArray);

	nArray = new int[protrudes.size()];
	for(int i = 0; i < nArray.length; i++)
	{
		nArray[i] = protrudes.get(i).index;
	}
	nbt.setIntArray("protrudes", nArray);

	nArray = new int[adjacent.size()];
	for(int i = 0; i < nArray.length; i++)
	{
		nArray[i] = adjacent.get(i).index;
	}
	nbt.setIntArray("adjacent", nArray);
}
 
Example 6
Source File: TileEntityFuelingStation.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);
	nbt.setByte("redstoneState", (byte) state.ordinal());
	if(hasMaster()) {
		nbt.setIntArray("masterPos", new int[] {masterBlock.x, masterBlock.y, masterBlock.z});
	}
	return nbt;
}
 
Example 7
Source File: DateEventHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack getFireworkCharge(){
    ItemStack charge = new ItemStack(Items.firework_charge);
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
    byte b0 = 0;
    ArrayList arraylist = new ArrayList();

    arraylist.add(Integer.valueOf(ItemDye.field_150922_c[rand.nextInt(16)]));

    if(rand.nextBoolean()) nbttagcompound1.setBoolean("Flicker", true);

    if(rand.nextBoolean()) nbttagcompound1.setBoolean("Trail", true);

    b0 = (byte)rand.nextInt(5);

    int[] aint = new int[arraylist.size()];

    for(int j2 = 0; j2 < aint.length; ++j2) {
        aint[j2] = ((Integer)arraylist.get(j2)).intValue();
    }

    nbttagcompound1.setIntArray("Colors", aint);
    nbttagcompound1.setByte("Type", b0);
    nbttagcompound.setTag("Explosion", nbttagcompound1);
    charge.setTagCompound(nbttagcompound);
    return charge;
}
 
Example 8
Source File: EntityElevatorCapsule.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
protected void writeEntityToNBT(NBTTagCompound nbt) {
	nbt.setByte("motionDir", motion);
	if(dstTilePos != null) {
		nbt.setInteger("dstDimid", dstTilePos.dimid);
		nbt.setIntArray("dstLoc", new int[] { dstTilePos.pos.x, dstTilePos.pos.y, dstTilePos.pos.z });
	}

	if(srcTilePos != null) {
		nbt.setInteger("srcDimid", srcTilePos.dimid);
		nbt.setIntArray("srcLoc", new int[] { srcTilePos.pos.x, srcTilePos.pos.y, srcTilePos.pos.z });
	}
}
 
Example 9
Source File: EntityRocket.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void disconnectInfrastructure(IInfrastructure infrastructure){
	infrastructure.unlinkRocket();
	infrastructureCoords.remove(new HashedBlockPosition(((TileEntity)infrastructure).getPos()));

	if(!world.isRemote) {
		int pos[] = {((TileEntity)infrastructure).getPos().getX(), ((TileEntity)infrastructure).getPos().getY(), ((TileEntity)infrastructure).getPos().getZ()};

		NBTTagCompound nbt = new NBTTagCompound();
		nbt.setIntArray("pos", pos);
		//PacketHandler.sendToPlayersTrackingEntity(new PacketEntity(this, (byte)PacketType.DISCONNECTINFRASTRUCTURE.ordinal(), nbt), this);
	}
}
 
Example 10
Source File: IslandParameters.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void writeToNBT(NBTTagCompound nbt)
{
	int feat = 0;
	NBTTagCompound fnbt = new NBTTagCompound();
	for(Feature ff : features)
	{
		fnbt.setBoolean(ff.toString(), true);
	}
	nbt.setTag("features", fnbt);
	nbt.setInteger("xCoord", xCoord);
	nbt.setInteger("zCoord", zCoord);
	nbt.setDouble("oceanRatio", oceanRatio);
	nbt.setDouble("lakeThreshold", lakeThreshold);
	nbt.setDouble("islandMaxHeight", islandMaxHeight);
	nbt.setInteger("surfaceRock", this.surfaceRock.getMeta());
	nbt.setString("treeCommon", treeCommon);
	nbt.setString("treeUncommon", treeUncommon);
	nbt.setString("treeRare", treeRare);
	nbt.setInteger("moisture", moisture.ordinal());
	nbt.setInteger("temp", temp.ordinal());
	nbt.setLong("seed", seed);

	String animals = "";
	for(int i = 0; i < animalTypes.size(); i++)
	{
		animals += animalTypes.get(i);
		if(i < animalTypes.size() - 1)
			animals += ",";
	}
	nbt.setString("animalTypes", animals);

	int[] cropArray = new int[cropList.size()];
	for(int i = 0; i < cropArray.length; i++)
	{
		cropArray[i] = cropList.get(i).getID();
	}
	nbt.setIntArray("crops", cropArray);
}
 
Example 11
Source File: TileEntityBeefBase.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public void writeToNBT(NBTTagCompound tag) {
	super.writeToNBT(tag);
	
	tag.setInteger("facing", facing);
	tag.setIntArray("exposures", exposures);
}
 
Example 12
Source File: CraftMetaFirework.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
static void addColors(NBTTagCompound compound, ItemMetaKey key, List<Color> colors) {
    if (colors.isEmpty()) {
        return;
    }

    final int[] colorArray = new int[colors.size()];
    int i = 0;
    for (Color color : colors) {
        colorArray[i++] = color.asRGB();
    }

    compound.setIntArray(key.NBT, colorArray);
}
 
Example 13
Source File: AbstractPair.java    From NEI-Integration with MIT License 5 votes vote down vote up
protected void saveNBT(NBTTagCompound data) {
    NBTTagList list = new NBTTagList();
    for (WorldCoordinate c : pairings) {
        NBTTagCompound tag = new NBTTagCompound();
        tag.setIntArray("coords", new int[]{c.dimension, c.x, c.y, c.z});
        list.appendTag(tag);
    }
    data.setTag("pairings", list);
}
 
Example 14
Source File: CellSavedWorldData.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
	compound.setInteger("index", storageIndex);
	for (String s : storageCells.keySet()) {
		int[] temp = new int[6];
		for (int i = 0; i < storageCells.get(s).length; i++) {
			if (storageCells.get(s)[i] != null) {
				temp[i] = storageCells.get(s)[i];
			}
		}
		compound.setIntArray(s, temp);
	}

	return compound;
}
 
Example 15
Source File: BaseVehicleEntity.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected void writeEntityToNBT(NBTTagCompound compound) {
	compound.setIntArray("qube", dataManager.get(QUBE).serialize());
	BlockPos b = dataManager.get(OFFSET);
	compound.setIntArray("offset", new int[] { b.getX(), b.getY(), b.getZ() });
}
 
Example 16
Source File: SchematicMetadata.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
public NBTTagCompound toTag()
{
    NBTTagCompound nbt = new NBTTagCompound();

    nbt.setString("Name", this.name);
    nbt.setString("Author", this.author);
    nbt.setString("Description", this.description);

    if (this.regionCount > 0)
    {
        nbt.setInteger("RegionCount", this.regionCount);
    }

    if (this.totalVolume > 0)
    {
        nbt.setLong("TotalVolume", this.totalVolume);
    }

    if (this.totalBlocks >= 0)
    {
        nbt.setLong("TotalBlocks", this.totalBlocks);
    }

    if (this.timeCreated > 0)
    {
        nbt.setLong("TimeCreated", this.timeCreated);
    }

    if (this.timeModified > 0)
    {
        nbt.setLong("TimeModified", this.timeModified);
    }

    nbt.setTag("EnclosingSize", NBTUtils.createBlockPosTag(this.enclosingSize));

    if (this.thumbnailPixelData != null)
    {
        nbt.setIntArray("PreviewImageData", this.thumbnailPixelData);
    }

    return nbt;
}
 
Example 17
Source File: GT_TileEntity_LESU.java    From bartworks with MIT License 4 votes vote down vote up
@Override
public void saveNBTData(NBTTagCompound aNBT) {
    aNBT.setIntArray("customCircuitInv", GT_Utility.stacksToIntArray(this.circuits));
    super.saveNBTData(aNBT);
}
 
Example 18
Source File: Center.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
public void writeToNBT(NBTTagCompound nbt)
{
	nbt.setInteger("index", index);
	nbt.setInteger("biome", biome.ordinal());
	nbt.setDouble("xCoord", point.x);
	nbt.setDouble("yCoord", point.y);
	long f = 0;
	for(Marker ff : flags)
	{
		f += ff.getFlag();
	}
	nbt.setLong("flags", f);
	nbt.setDouble("elevation", elevation);
	nbt.setFloat("moisture", moisture);
	nbt.setBoolean("hasGenerated", hasGenerated);


	if(downslope != null)
		nbt.setInteger("downslope", downslope.index);

	int[] nArray = new int[neighbors.size()];
	for(int i = 0; i < nArray.length; i++)
	{
		nArray[i] = neighbors.get(i).index;
	}
	nbt.setIntArray("neighbors", nArray);

	nArray = new int[corners.size()];
	for(int i = 0; i < nArray.length; i++)
	{
		nArray[i] = corners.get(i).index;
	}
	nbt.setIntArray("corners", nArray);

	nArray = new int[borders.size()];
	for(int i = 0; i < nArray.length; i++)
	{
		nArray[i] = borders.get(i).index;
	}
	nbt.setIntArray("borders", nArray);

	Iterator<Attribute> iter = attribMap.values().iterator();
	NBTTagList attribList = new NBTTagList();
	while(iter.hasNext())
	{
		Attribute a = iter.next();
		NBTTagCompound attribNBT = new NBTTagCompound();
		attribNBT.setString("class", a.getClass().getName());
		a.writeToNBT(attribNBT);
		attribList.appendTag(attribNBT);
	}
	nbt.setTag("attribMap", attribList);

	nbt.setTag("CustomData", this.customNBT);
}
 
Example 19
Source File: TileSpaceElevator.java    From AdvancedRocketry with MIT License 3 votes vote down vote up
@Override
public void writeNetworkData(NBTTagCompound nbt) {


	if(dimBlockPos != null)
	{
		nbt.setInteger("dstDimId", dimBlockPos.dimid);
		nbt.setIntArray("dstPos", new int[] { dimBlockPos.pos.x, dimBlockPos.pos.y, dimBlockPos.pos.z });

	}

	super.writeNetworkData(nbt);
}
 
Example 20
Source File: TilePlanetSelector.java    From AdvancedRocketry with MIT License 3 votes vote down vote up
public void writeAdditionalNBT(NBTTagCompound nbt) {
	if(getMasterBlock() != null) {
		List<Integer> list = ((ITilePlanetSystemSelectable)getMasterBlock()).getVisiblePlanets();

		Integer[] intList = new Integer[list.size()];

		nbt.setIntArray("visiblePlanets",ArrayUtils.toPrimitive(list.toArray(intList)));
	}

}