Java Code Examples for net.minecraft.block.Block#getBlockById()

The following examples show how to use net.minecraft.block.Block#getBlockById() . 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: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getOpacity(ExtendedBlockStorage section, int x, int y, int z) {
    int combined = getCombinedId4Data(section, x, y, z);
    if (combined == 0) {
        return 0;
    }
    Block block = Block.getBlockById(FaweCache.getId(combined));
    return block.getLightOpacity();
}
 
Example 2
Source File: EntityREP.java    From WirelessRedstone with MIT License 5 votes vote down vote up
public void readEntityFromNBT(NBTTagCompound tag) {
    xTileREP = tag.getShort("xTile");
    yTileREP = tag.getShort("yTile");
    zTileREP = tag.getShort("zTile");
    inTileREP = Block.getBlockById(tag.getShort("inTile") & 0xFFFF);
    shakeREP = tag.getByte("shake") & 0xff;
    inGroundREP = tag.getByte("inGround") == 1;
}
 
Example 3
Source File: TileEntityQuantumComputer.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
public static AreaData decode( NBTTagCompound nbttagcompound )
{
    AreaData storedData = new AreaData();
    storedData.m_shape = new AreaShape();
    storedData.m_shape.m_xMin = nbttagcompound.getInteger( "xmin" );
    storedData.m_shape.m_xMax = nbttagcompound.getInteger( "xmax" );
    storedData.m_shape.m_yMin = nbttagcompound.getInteger( "ymin" );
    storedData.m_shape.m_yMax = nbttagcompound.getInteger( "ymax" );
    storedData.m_shape.m_zMin = nbttagcompound.getInteger( "zmin" );
    storedData.m_shape.m_zMax = nbttagcompound.getInteger( "zmax" );

    int size =
        ( storedData.m_shape.m_xMax - storedData.m_shape.m_xMin + 1 ) *
        ( storedData.m_shape.m_yMax - storedData.m_shape.m_yMin + 1 ) *
        ( storedData.m_shape.m_zMax - storedData.m_shape.m_zMin + 1 );
    storedData.m_blocks = new Block[ size ];
    if( nbttagcompound.hasKey( "blockData" ) )
    {
        int[] blockIDs = nbttagcompound.getIntArray( "blockData" );
        for( int i=0; i<size; ++i )
        {
            storedData.m_blocks[i] = Block.getBlockById( blockIDs[i] );
        }
    }
    else
    {
        NBTTagList blockNames = nbttagcompound.getTagList( "blockNames", Constants.NBT.TAG_STRING );
        for( int i=0; i<size; ++i )
        {
            String name = blockNames.getStringTagAt( i );
            if( name.length() > 0 && !name.equals( "null" ) )
            {
                storedData.m_blocks[i] = Block.getBlockFromName( name );
            }
        }
    }
    storedData.m_metaData = nbttagcompound.getIntArray( "metaData" );
    return storedData;
}
 
Example 4
Source File: LocatedBlock.java    From archimedes-ships with MIT License 5 votes vote down vote up
public LocatedBlock(NBTTagCompound comp, World world)
{
	block = Block.getBlockById(comp.getInteger("block"));
	blockMeta = comp.getInteger("meta");
	coords = new ChunkPosition(comp.getInteger("x"), comp.getInteger("y"), comp.getInteger("z"));
	tileEntity = world == null ? null : world.getTileEntity(coords.chunkPosX, coords.chunkPosY, coords.chunkPosZ);
}
 
Example 5
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getOpacityBrightnessPair(ExtendedBlockStorage section, int x, int y, int z) {
    int combined = getCombinedId4Data(section, x, y, z);
    if (combined == 0) {
        return 0;
    }
    Block block = Block.getBlockById(FaweCache.getId(combined));
    return MathMan.pair16(block.getLightOpacity(), block.getLightValue());
}
 
Example 6
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getBrightness(ExtendedBlockStorage section, int x, int y, int z) {
    int combined = getCombinedId4Data(section, x, y, z);
    if (combined == 0) {
        return 0;
    }
    Block block = Block.getBlockById(FaweCache.getId(combined));
    return block.getLightValue();
}
 
Example 7
Source File: EntityThrowableEU.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void readEntityFromNBT(NBTTagCompound nbt)
{
    this.blockX = nbt.getShort("xTile");
    this.blockY = nbt.getShort("yTile");
    this.blockZ = nbt.getShort("zTile");
    this.inBlock = Block.getBlockById(nbt.getByte("inTile") & 255);
    this.throwableShake = nbt.getByte("shake") & 255;
    this.inGround = nbt.getByte("inGround") == 1;

    if (nbt.hasKey("ownerUUIDM", Constants.NBT.TAG_LONG) && nbt.hasKey("ownerUUIDL", Constants.NBT.TAG_LONG))
    {
        this.throwerUUID = new UUID(nbt.getLong("ownerUUIDM"), nbt.getLong("ownerUUIDL"));
    }
}
 
Example 8
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getBrightness(ExtendedBlockStorage section, int x, int y, int z) {
    int combined = getCombinedId4Data(section, x, y, z);
    if (combined == 0) {
        return 0;
    }
    Block block = Block.getBlockById(FaweCache.getId(combined));
    return block.getLightValue();
}
 
Example 9
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getOpacity(ExtendedBlockStorage section, int x, int y, int z) {
    int combined = getCombinedId4Data(section, x, y, z);
    if (combined == 0) {
        return 0;
    }
    Block block = Block.getBlockById(FaweCache.getId(combined));
    return block.getLightOpacity();
}
 
Example 10
Source File: EntityLaser.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
    this.xTile = par1NBTTagCompound.getShort("xTile");
    this.yTile = par1NBTTagCompound.getShort("yTile");
    this.zTile = par1NBTTagCompound.getShort("zTile");
    this.inTile = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255);
    this.inData = par1NBTTagCompound.getByte("inData") & 255;
    this.inGround = par1NBTTagCompound.getByte("inGround") == 1;
}
 
Example 11
Source File: EntityLaser.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
	this.xTile = par1NBTTagCompound.getShort("xTile");
	this.yTile = par1NBTTagCompound.getShort("yTile");
	this.zTile = par1NBTTagCompound.getShort("zTile");
	this.inTile = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255);
	this.inData = par1NBTTagCompound.getByte("inData") & 255;
	this.inGround = par1NBTTagCompound.getByte("inGround") == 1;
}
 
Example 12
Source File: EntitySpecialArrow.java    From Artifacts with MIT License 5 votes vote down vote up
public void readEntityFromNBT(NBTTagCompound tag)
{
	super.readEntityFromNBT(tag);
	this.xTile = tag.getShort("xTile");
	this.yTile = tag.getShort("yTile");
	this.zTile = tag.getShort("zTile");
	this.inTile = Block.getBlockById(tag.getByte("inTile") & 0xFF);
	this.inData = (tag.getByte("inData") & 0xFF);
	this.inGround = (tag.getByte("inGround") == 1);
	this.effect = ArrowEffect.get(tag.getByte("effect"));
}
 
Example 13
Source File: BlockESP.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@EventTarget
public void onUpdate(UpdateEvent event) {
    if(searchTimer.hasTimePassed(1000L) && (thread == null || !thread.isAlive())) {
        final int radius = radiusValue.get();
        final Block selectedBlock = Block.getBlockById(blockValue.get());

        if(selectedBlock == null || selectedBlock == Blocks.air)
            return;

        thread = new Thread(() -> {
            final List<BlockPos> blockList = new ArrayList<>();

            for(int x = -radius; x < radius; x++) {
                for(int y = radius; y > -radius; y--) {
                    for(int z = -radius; z < radius; z++) {
                        final int xPos = ((int) mc.thePlayer.posX + x);
                        final int yPos = ((int) mc.thePlayer.posY + y);
                        final int zPos = ((int) mc.thePlayer.posZ + z);

                        final BlockPos blockPos = new BlockPos(xPos, yPos, zPos);
                        final Block block = BlockUtils.getBlock(blockPos);
                        if(block == selectedBlock)
                            blockList.add(blockPos);
                    }
                }
            }

            searchTimer.reset();

            synchronized(posList) {
                posList.clear();
                posList.addAll(blockList);
            }
        }, "BlockESP-BlockFinder");
        thread.start();
    }
}
 
Example 14
Source File: BlockEntry.java    From ForgeHax with MIT License 4 votes vote down vote up
public BlockEntry(int id, int meta) throws BlockDoesNotExistException {
  this(Block.getBlockById(id), meta, !BlockOptionHelper.isAir(id));
}
 
Example 15
Source File: PacketBreakParticle.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
	this.block = Block.getBlockById(buf.readInt());
	this.pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
}
 
Example 16
Source File: TileEntityBlockMateralProxy.java    From GardenCollection with MIT License 4 votes vote down vote up
private void unpackUnifiedProtoData (int protoData) {
    protoBlock = Block.getBlockById(protoData & 0xFFFF);
    protoMeta = (protoData >> 16) & 0xFFFF;
}
 
Example 17
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);
						}
					}
				}
			}
		}
	}*/

}
 
Example 18
Source File: StorageChunk.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
public void readFromNetwork(ByteBuf in) {
	PacketBuffer buffer = new PacketBuffer(in);

	this.sizeX = buffer.readByte();
	this.sizeY = buffer.readByte();
	this.sizeZ = buffer.readByte();
	short numTiles = buffer.readShort();

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

	for(int x = 0; x < sizeX; x++) {
		for(int y = 0; y < sizeY; y++) {
			for(int z = 0; z < sizeZ; z++) {
				this.blocks[x][y][z] = Block.getBlockById(buffer.readInt());
				this.metas[x][y][z] = buffer.readShort();
			}
		}
	}

	for(short i = 0; i < numTiles; i++) {
		try {
			NBTTagCompound nbt = buffer.readCompoundTag();

			TileEntity tile = ZUtils.createTile(nbt);
			tile.setWorld(world);
			tileEntities.add(tile);

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

			if(isLiquidContainerBlock(tile))
				liquidTiles.add(tile);
			tile.setWorld(world);

		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	//We are now ready to render
	finalized = true;
}
 
Example 19
Source File: MappingRegistry.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
public int blockIdToRegistry(int id) {
	Block block = Block.getBlockById(id);

	return getIdForBlock(block);
}
 
Example 20
Source File: BlockMetaPair.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
public Block getBlock() {
	return Block.getBlockById(id);
}