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

The following examples show how to use net.minecraft.nbt.NBTTagCompound#getIntArray() . 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: Corner.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
public void readFromNBT(NBTTagCompound nbt, IslandMap m)
{
	this.point = new Point(nbt.getDouble("xCoord"), nbt.getDouble("yCoord"));
	setMarkers(nbt.getInteger("flags"));
	elevation = nbt.getDouble("elevation");
	moisture = nbt.getDouble("moisture");

	int[] nArray = nbt.getIntArray("touches");
	for(int i = 0; i < nArray.length; i++)
	{
		this.touches.add(m.centers.get(nArray[i]));
	}
	nArray = nbt.getIntArray("adjacent");
	for(int i = 0; i < nArray.length; i++)
	{
		this.adjacent.add(m.corners.get(nArray[i]));
	}
	nArray = nbt.getIntArray("protrudes");
	for(int i = 0; i < nArray.length; i++)
	{
		this.protrudes.add(m.edges.get(nArray[i]));
	}
}
 
Example 2
Source File: SatelliteBiomeChanger.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	biomeId = nbt.getInteger("biomeId");

	int array[] = nbt.getIntArray("posList");

	toChangeList.clear();
	for(int i = 0; i < array.length; i +=3) {
		toChangeList.add(new HashedBlockPosition(array[i], array[i+1], array[i+2]));
	}

	array = nbt.getIntArray("biomeList");
	discoveredBiomes.clear();
	for(int i = 0; i < array.length; i ++) {
		discoveredBiomes.add((byte) array[i]);
	}
}
 
Example 3
Source File: RiverAttribute.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt, com.bioxx.jmapgen.IslandMap m) 
{
	this.id = UUID.fromString(nbt.getString("uuid"));
	river = nbt.getDouble("river");
	if(nbt.hasKey("downriver"))
		downriver = m.centers.get(nbt.getInteger("downriver"));
	if(nbt.hasKey("upriver"))
	{
		int[] nArray = nbt.getIntArray("upriver");
		upriver = new Vector<Center>();
		for(int i = 0; i < nArray.length; i++)
		{
			this.upriver.add(m.centers.get(nArray[i]));
		}
	}

	this.riverMid = new Point(nbt.getInteger("midX"), nbt.getInteger("midY"));
	this.deadRiver = nbt.getBoolean("isDead");
}
 
Example 4
Source File: GTItemSensorStick.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static EnumActionResult tryParseCoords(IGTCoordinateTile coordTile, World world, EntityPlayer player,
		EnumHand hand) {
	NBTTagCompound nbt = StackUtil.getNbtData(player.getHeldItem(hand));
	if (nbt.getIntArray(POS).length == 4) {
		int[] posArr = nbt.getIntArray(POS);
		if (!coordTile.isInterdimensional() && posArr[3] != world.provider.getDimension()) {
			IC2.platform.messagePlayer(player, "This machine does not support interdimensional communication");
			return EnumActionResult.SUCCESS;
		}
		ItemStack playerStack = player.getHeldItem(hand);
		if (coordTile.insertSensorStick(playerStack)) {
			coordTile.applyCoordinates(new BlockPos(posArr[0], posArr[1], posArr[2]), posArr[3]);
			player.getHeldItem(hand).shrink(1);
			IC2.platform.messagePlayer(player, "Sensor Stick successfully installed into machine!");
			return EnumActionResult.SUCCESS;
		} else {
			IC2.platform.messagePlayer(player, "Sensor Stick already found in machine");
			return EnumActionResult.SUCCESS;
		}
	}
	IC2.platform.messagePlayer(player, "Sensor Card cannot be installed in this!");
	return EnumActionResult.SUCCESS;
}
 
Example 5
Source File: GTItemSensorStick.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
	NBTTagCompound nbt = StackUtil.getNbtData(stack);
	if (nbt.getIntArray(POS).length == 4) {
		tooltip.add("Click a valid block to install Sensor Stick into machine");
		int[] pos = nbt.getIntArray(POS);
		tooltip.add(TextFormatting.YELLOW + I18n.format("Last Scanned: "));
		if (nbt.getString(BLOCK) != null) {
			tooltip.add(TextFormatting.BLUE + I18n.format(nbt.getString(BLOCK)));
		}
		tooltip.add(TextFormatting.BLUE + I18n.format("X: " + pos[0] + " Y: " + pos[1] + " Z: " + pos[2]));
		tooltip.add(TextFormatting.BLUE + I18n.format("Dimension: " + pos[3]));
	} else {
		tooltip.add("Click a block to set coordinates to internal memory");
	}
}
 
Example 6
Source File: ItemArtifact.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public boolean canHarvestBlock(Block block, ItemStack itemStack) {
   	NBTTagCompound data = itemStack.getTagCompound();
	int effectID = 0;
	if(data != null) {
		/*effectID = data.getInteger("onBlockDestroyed");
		if(effectID != 0) {
			ArtifactComponent c = Artifact.getComponent(effectID);
			return c.canHarvestBlock(par1Block, itemStack);
		}
		effectID = data.getInteger("canHarvestBlock");
		if(effectID != 0) {
			ArtifactComponent c = Artifact.getComponent(effectID);
			return c.canHarvestBlock(par1Block, itemStack);
		}*/
		int ca[] = data.getIntArray("allComponents");
		boolean r = false;
		for(int i=ca.length-1; i >= 0; i--) {
			if(ca[i] != 0) {
				IArtifactComponent c = ArtifactsAPI.artifacts.getComponent(ca[i]);
				if(c != null)
					r = r || c.canHarvestBlock(block, itemStack);
			}
		}
	}
	return false;
   }
 
Example 7
Source File: NBTStorableListList.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void readFromNBT(NBTTagCompound nbt) {
	
	NBTTagList list = nbt.getTagList("list", NBT.TAG_COMPOUND);
	pos.clear();
	for(int i = 0; i < list.tagCount(); i++) {
		NBTTagCompound nbttag = list.getCompoundTagAt(i);
		int[] tag = nbttag.getIntArray("loc");
		int dimid = nbttag.getInteger("dim");
		
		pos.add(new DimensionBlockPosition(dimid, new HashedBlockPosition(tag[0], tag[1], tag[2])));
	}
}
 
Example 8
Source File: DataConverter.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Reads an unknown object withPriority a known name from NBT
 * @param tag - tag to read the value from
 * @param key - name of the value
 * @return object or suggestionValue if nothing is found
 */
@Nullable
public Object load(@Nullable NBTTagCompound tag, @Nullable String key) {
	if (tag != null && key != null) {
		NBTBase saveTag = tag.getTag(key);

		if (saveTag instanceof NBTTagFloat) {
			return tag.getFloat(key);
		} else if (saveTag instanceof NBTTagDouble) {
			return tag.getDouble(key);
		} else if (saveTag instanceof NBTTagInt) {
			return tag.getInteger(key);
		} else if (saveTag instanceof NBTTagString) {
			return tag.getString(key);
		} else if (saveTag instanceof NBTTagShort) {
			return tag.getShort(key);
		} else if (saveTag instanceof NBTTagByte) {
			if (tag.getBoolean("isBoolean")) {
				return tag.getBoolean(key);
			} else {
				return tag.getByte(key);
			}
		} else if (saveTag instanceof NBTTagLong) {
			return tag.getLong(key);
		} else if (saveTag instanceof NBTTagByteArray) {
			return tag.getByteArray(key);
		} else if (saveTag instanceof NBTTagIntArray) {
			return tag.getIntArray(key);
		} else if (saveTag instanceof NBTTagCompound) {
			NBTTagCompound innerTag = tag.getCompoundTag(key);
			return toNova(innerTag);
		}
	}
	return null;
}
 
Example 9
Source File: AbstractPair.java    From NEI-Integration with MIT License 5 votes vote down vote up
protected void loadNBT(NBTTagCompound data) {
    NBTTagList list = data.getTagList("pairings", 10);
    for (byte entry = 0; entry < list.tagCount(); entry++) {
        NBTTagCompound tag = list.getCompoundTagAt(entry);
        int[] c = tag.getIntArray("coords");
        pairings.add(new WorldCoordinate(c[0], c[1], c[2], c[3]));
    }
}
 
Example 10
Source File: TileLandingPad.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	blockPos.clear();
	if(nbt.hasKey("infrastructureLocations")) {
		int array[] = nbt.getIntArray("infrastructureLocations");

		for(int counter = 0; counter < array.length; counter += 3) {
			blockPos.add(new HashedBlockPosition(array[counter], array[counter+1], array[counter+2]));
		}
	}
	name = nbt.getString("name");
}
 
Example 11
Source File: TileEntityElevatorBase.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void readFromPacket(NBTTagCompound tag){
    super.readFromPacket(tag);
    floorHeights = tag.getIntArray("floorHeights");

    floorNames.clear();
    NBTTagList floorNameList = tag.getTagList("floorNames", 10);
    for(int i = 0; i < floorNameList.tagCount(); i++) {
        NBTTagCompound floorName = floorNameList.getCompoundTagAt(i);
        floorNames.put(floorName.getInteger("floorHeight"), floorName.getString("floorName"));
    }
}
 
Example 12
Source File: TileEntityFuelingStation.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	state = RedstoneState.values()[nbt.getByte("redstoneState")];
	redstoneControl.setRedstoneState(state);

	if(nbt.hasKey("masterPos")) {
		int[] pos = nbt.getIntArray("masterPos");
		setMasterBlock(new BlockPos(pos[0], pos[1], pos[2]));
	}
}
 
Example 13
Source File: ItemArtifact.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
  public int getHarvestLevel(ItemStack itemStack, String toolClass)
  {
  	NBTTagCompound data = itemStack.getTagCompound();
int effectID = 0;
int r = -1;
if(data != null) {
	int ca[] = data.getIntArray("allComponents");
	
	//Loop through the components and find the one with the highest harvest level.
	for(int i=ca.length-1; i >= 0; i--) {
		if(ca[i] != 0) {
			int temp = 0;
			IArtifactComponent c = ArtifactsAPI.artifacts.getComponent(ca[i]);
			if(c != null)
				temp = c.getHarvestLevel(itemStack, toolClass);
			if(temp > r) {
				r = temp;
			}
		}
	}
}

//Return the highest harvest level.
//System.out.println("Tool Type is: '"+toolClass+"', and Harvest Level is " + r);
return r;
  }
 
Example 14
Source File: IslandParameters.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void readFromNBT(NBTTagCompound nbt)
{
	NBTTagCompound fnbt = nbt.getCompoundTag("features");
	for(Feature f : Feature.values())
	{
		if(fnbt.hasKey(f.toString()))
			features.add(f);
	}
	this.setCoords(nbt.getInteger("xCoord"), nbt.getInteger("zCoord"));
	this.oceanRatio = nbt.getDouble("oceanRatio");
	this.lakeThreshold = nbt.getDouble("lakeThreshold");
	this.islandMaxHeight = nbt.getDouble("islandMaxHeight");
	this.surfaceRock = StoneType.getStoneTypeFromMeta(nbt.getInteger("surfaceRock"));
	this.treeCommon = nbt.getString("treeCommon");
	this.treeUncommon = nbt.getString("treeUncommon");
	this.treeRare = nbt.getString("treeRare");
	this.moisture = Moisture.values()[nbt.getInteger("moisture")];
	this.temp = ClimateTemp.values()[nbt.getInteger("temp")];
	this.seed = nbt.getLong("seed");

	this.animalTypes = new ArrayList<String>();
	String animals = nbt.getString("animalTypes");
	String[] split = animals.split(",");
	for(int i = 0; i < split.length; i++)
	{
		animalTypes.add(split[i]);
	}

	cropList.clear();
	int[] cropArray = nbt.getIntArray("crops");
	for(int i = 0; i < cropArray.length; i++)
	{
		cropList.add(Crop.fromID(cropArray[i]));
	}
}
 
Example 15
Source File: TilePlanetSelector.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void readAdditionalNBT(NBTTagCompound nbt) {
	if(container != null) {
		int[] intArray = nbt.getIntArray("visiblePlanets");
		for(int id : intArray)
			container.setPlanetAsKnown(id);
	}
}
 
Example 16
Source File: ItemArtifact.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public float getDigSpeed(ItemStack itemStack, Block block, int meta)
   {
	NBTTagCompound data = itemStack.getTagCompound();
	int effectID = 0;
	float s;
	if(data != null) {
		/*effectID = data.getInteger("onBlockDestroyed");
		if(effectID != 0) {
			ArtifactComponent c = Artifact.getComponent(effectID);
			s = c.getStrVsBlock(par1ItemStack, par2Block);
			if(s > 0)
				return s;
		}
		if(effectID != 0) {
			ArtifactComponent c = Artifact.getComponent(effectID);
			s = c.getStrVsBlock(par1ItemStack, par2Block);
			if(s > 0)
				return s;
		}*/
		int ca[] = data.getIntArray("allComponents");
		float r = 0, y=0;
		for(int i=ca.length-1; i >= 0; i--) {
			if(ca[i] != 0) {
				IArtifactComponent c = ArtifactsAPI.artifacts.getComponent(ca[i]);
				if(c != null)
					y = c.getDigSpeed(itemStack, block, meta);
				if(y > r)
					r = y;
			}
		}
		//System.out.println("str: " + r);
		if(r > 0)
			return r;
	}
	//System.out.println("No strength");
       return 0.25F;// * EnumToolMaterial.values()[par1ItemStack.stackTagCompound.getInteger("material")].getEfficiencyOnProperMaterial();
   }
 
Example 17
Source File: CellSavedWorldData.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound nbt) {
 	storageIndex = nbt.getInteger("index");
	for (String s : nbt.getKeySet()) {
		Integer[] temp = new Integer[6];
		for (int i = 0; i < nbt.getIntArray(s).length; i++)
			temp[i] = nbt.getIntArray(s)[i];
		storageCells.put(s, temp);
	}
}
 
Example 18
Source File: SchematicMetadata.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void fromTag(NBTTagCompound tag)
{
    if (tag.hasKey("Name", Constants.NBT.TAG_STRING))
    {
        this.name = tag.getString("Name");
    }

    if (tag.hasKey("Author", Constants.NBT.TAG_STRING))
    {
        this.author = tag.getString("Author");
    }

    if (tag.hasKey("Description", Constants.NBT.TAG_STRING))
    {
        this.description = tag.getString("Description");
    }

    if (tag.hasKey("RegionCount", Constants.NBT.TAG_INT))
    {
        this.regionCount = tag.getInteger("RegionCount");
    }

    if (tag.hasKey("TotalVolume", Constants.NBT.TAG_LONG) || tag.hasKey("TotalVolume", Constants.NBT.TAG_INT))
    {
        this.totalVolume = tag.getLong("TotalVolume");
    }

    if (tag.hasKey("TotalBlocks", Constants.NBT.TAG_LONG) || tag.hasKey("TotalBlocks", Constants.NBT.TAG_INT))
    {
        this.totalBlocks = tag.getLong("TotalBlocks");
    }

    if (tag.hasKey("TimeCreated", Constants.NBT.TAG_LONG))
    {
        this.timeCreated = tag.getLong("TimeCreated");
    }

    if (tag.hasKey("TimeModified", Constants.NBT.TAG_LONG))
    {
        this.timeModified = tag.getLong("TimeModified");
    }

    if (tag.hasKey("EnclosingSize", Constants.NBT.TAG_COMPOUND))
    {
        Vec3i size = NBTUtils.readBlockPos(tag.getCompoundTag("EnclosingSize"));

        if (size != null)
        {
            this.enclosingSize = size;
        }
    }

    if (tag.hasKey("PreviewImageData", Constants.NBT.TAG_INT_ARRAY))
    {
        this.thumbnailPixelData = tag.getIntArray("PreviewImageData");
    }
    else
    {
        this.thumbnailPixelData = null;
    }
}
 
Example 19
Source File: SyncableIntArray.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag, String name) {
	value = tag.getIntArray(name);
}
 
Example 20
Source File: StorageChunk.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
public void readFromNBT(NBTTagCompound nbt) {
	sizeX = nbt.getInteger("xSize");
	sizeY = nbt.getInteger("ySize");
	sizeZ = nbt.getInteger("zSize");

	blocks = new Block[sizeX][sizeY][sizeZ];
	metas = new short[sizeX][sizeY][sizeZ];

	tileEntities.clear();
	inventoryTiles.clear();
	liquidTiles.clear();

	int[] blockId = nbt.getIntArray("idList");
	int[] metasId = nbt.getIntArray("metaList");

	for(int x = 0; x < sizeX; x++) {
		for(int y = 0; y < sizeY; y++) {
			for(int z = 0; z < sizeZ; z++) {
				blocks[x][y][z] = Block.getBlockById(blockId[z + (sizeZ*y) + (sizeZ*sizeY*x)]);
				metas[x][y][z] = (short)metasId[z + (sizeZ*y) + (sizeZ*sizeY*x)];
			}
		}
	}

	NBTTagList tileList = nbt.getTagList("tiles", NBT.TAG_COMPOUND);

	for(int i = 0; i < tileList.tagCount(); i++) {

		try {
			TileEntity tile = ZUtils.createTile(tileList.getCompoundTagAt(i));
			tile.setWorld(world);

			if(isInventoryBlock(tile)) {
				inventoryTiles.add(tile);
			}

			if(isLiquidContainerBlock(tile)) {
				liquidTiles.add(tile);
			}

			tileEntities.add(tile);
			tile.setWorld(world);
		} catch (Exception e) {
			AdvancedRocketry.logger.warn("Rocket missing Tile (was a mod removed?)");
		}

	}

	/*for(int x = 0; x < sizeX; x++) {
		for(int y = 0; y < sizeY; y++) {
			for(int z = 0; z < sizeZ; z++) {



				NBTTagCompound tag = (NBTTagCompound)nbt.getTag(String.format("%d.%d.%d", x,y,z));

				if(!tag.hasKey("block"))
					continue;
				int blockId = tag.getInteger("block"); 
				blocks[x][y][z] = Block.getBlockById(blockId);
				metas[x][y][z] = tag.getShort("meta");


				if(blockId != 0 && blocks[x][y][z] == Blocks.air) {
					AdvancedRocketry.logger.warn("Removed pre-existing block with id " + blockId + " from a rocket (Was a mod removed?)");
				}
				else if(tag.hasKey("tile")) {

					if(blocks[x][y][z].hasTileEntity(metas[x][y][z])) {
						TileEntity tile = TileEntity.createAndLoadEntity(tag.getCompoundTag("tile"));
						tile.setWorldObj(world);

						tileEntities.add(tile);

						//Machines would throw a wrench in the works
						if(isUsableBlock(tile)) {
							inventories.add((IInventory)tile);
							usableTiles.add(tile);
						}
					}
				}
			}
		}
	}*/

}