Java Code Examples for net.minecraft.world.World#getBlockId()
The following examples show how to use
net.minecraft.world.World#getBlockId() .
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: HayCrook.java From Ex-Aliquo with MIT License | 6 votes |
@Override public boolean onBlockStartBreak(ItemStack item, int X, int Y, int Z, EntityPlayer player) { World world = player.worldObj; int blockID = world.getBlockId(X,Y,Z); int meta = world.getBlockMetadata(X, Y, Z); boolean validTarget = false; Block block = Block.blocksList[blockID]; if (block.isBlockReplaceable(null, 0, 0, 0)) { block.dropBlockAsItem(world, X, Y, Z, meta, 2); } return true; }
Example 2
Source File: MoCBlockLog.java From mocreaturesdev with GNU General Public License v3.0 | 6 votes |
/** * ejects contained items into the world, and notifies neighbours of an update, as appropriate */ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { byte var7 = 4; int var8 = var7 + 1; if (par1World.checkChunksExist(par2 - var8, par3 - var8, par4 - var8, par2 + var8, par3 + var8, par4 + var8)) { for (int var9 = -var7; var9 <= var7; ++var9) { for (int var10 = -var7; var10 <= var7; ++var10) { for (int var11 = -var7; var11 <= var7; ++var11) { int var12 = par1World.getBlockId(par2 + var9, par3 + var10, par4 + var11); if (Block.blocksList[var12] != null) { Block.blocksList[var12].beginLeavesDecay(par1World, par2 + var9, par3 + var10, par4 + var11); } } } } } }
Example 3
Source File: MoCBlockLeaf.java From mocreaturesdev with GNU General Public License v3.0 | 6 votes |
public void onBlockRemoval(World world, int i, int j, int k) { int l = 1; int i1 = l + 1; if(world.checkChunksExist(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) { for(int j1 = -l; j1 <= l; j1++) { for(int k1 = -l; k1 <= l; k1++) { for(int l1 = -l; l1 <= l; l1++) { int i2 = world.getBlockId(i + j1, j + k1, k + l1); if(i2 == Block.sapling.blockID) ///////Leaf///////////// { int j2 = world.getBlockMetadata(i + j1, j + k1, k + l1); world.setBlockMetadataWithNotify(i + j1, j + k1, k + l1, j2 | 8,3); } } } } } }
Example 4
Source File: ItemBlockCertusTank.java From ExtraCells1 with MIT License | 6 votes |
@Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { if (!world.setBlock(x, y, z, getBlockID(), metadata, 3)) { return false; } if (world.getBlockId(x, y, z) == getBlockID()) { Block.blocksList[getBlockID()].onBlockPlacedBy(world, x, y, z, player, stack); Block.blocksList[getBlockID()].onPostBlockPlaced(world, x, y, z, metadata); } if (stack != null && stack.hasTagCompound()) { ((TileEntityCertusTank) world.getBlockTileEntity(x, y, z)).readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity")); } return true; }
Example 5
Source File: MoCBlockLog.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
/** * Called whenever the block is removed. */ public void onBlockRemoval(World par1World, int par2, int par3, int par4) { byte byte0 = 4; int i = byte0 + 1; if (par1World.checkChunksExist(par2 - i, par3 - i, par4 - i, par2 + i, par3 + i, par4 + i)) { for (int j = -byte0; j <= byte0; j++) { for (int k = -byte0; k <= byte0; k++) { for (int l = -byte0; l <= byte0; l++) { int i1 = par1World.getBlockId(par2 + j, par3 + k, par4 + l); if (i1 != MoCreatures.mocLeaf.blockID) { continue; } int j1 = par1World.getBlockMetadata(par2 + j, par3 + k, par4 + l); if ((j1 & 8) == 0) { par1World.setBlockMetadataWithNotify(par2 + j, par3 + k, par4 + l, j1 | 8, 3); } } } } } }
Example 6
Source File: MoCBlockGrass.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (!MoCreatures.isServer()) { return; } if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && Block.lightOpacity[par1World.getBlockId(par2, par3 + 1, par4)] > 2) { //par1World.setBlockWithNotify(par2, par3, par4, MoCreatures.mocDirt.blockID); par1World.setBlock(par2, par3, par4, MoCreatures.mocDirt.blockID, this.getDamageValue(par1World, par2, par3, par4), 3); } else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9) { for (int i = 0; i < 45; i++) { int j = (par2 + par5Random.nextInt(3)) - 1; int k = (par3 + par5Random.nextInt(5)) - 3; int l = (par4 + par5Random.nextInt(3)) - 1; int i1 = par1World.getBlockId(j, k + 1, l); if (par1World.getBlockId(j, k, l) == MoCreatures.mocDirt.blockID && par1World.getBlockLightValue(j, k + 1, l) >= 4 && Block.lightOpacity[i1] <= 2) { par1World.setBlock(j, k, l, MoCreatures.mocGrass.blockID, this.getDamageValue(par1World, j, k, l), 3); } } } }
Example 7
Source File: WorldGenWyvernGrass.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) { int var11; Block block = null; do { block = Block.blocksList[par1World.getBlockId(par3, par4, par5)]; if (block != null && !block.isLeaves(par1World, par3, par4, par5)) { break; } par4--; } while (par4 > 0); for (int var7 = 0; var7 < 128; ++var7) { int var8 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); int var9 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); int var10 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); if (par1World.isAirBlock(var8, var9, var10) && Block.blocksList[this.tallGrassID].canBlockStay(par1World, var8, var9, var10)) { par1World.setBlock(var8, var9, var10, this.tallGrassID, this.tallGrassMetadata, 3); } } return true; }
Example 8
Source File: CustomSpawner.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
public static boolean isNearTorch(Entity entity, Double dist, World worldObj) { AxisAlignedBB axisalignedbb = entity.boundingBox.expand(dist, 2D, dist); int i = MathHelper.floor_double(axisalignedbb.minX); int j = MathHelper.floor_double(axisalignedbb.maxX + 1.0D); int k = MathHelper.floor_double(axisalignedbb.minY); int l = MathHelper.floor_double(axisalignedbb.maxY + 1.0D); int i1 = MathHelper.floor_double(axisalignedbb.minZ); int j1 = MathHelper.floor_double(axisalignedbb.maxZ + 1.0D); for (int k1 = i; k1 < j; k1++) { for (int l1 = k; l1 < l; l1++) { for (int i2 = i1; i2 < j1; i2++) { int j2 = worldObj.getBlockId(k1, l1, i2); if (j2 != 0) { String nameToCheck = ""; nameToCheck = Block.blocksList[j2].getUnlocalizedName();//.getBlockName(); if (nameToCheck != null && nameToCheck != "" && nameToCheck.equals("tile.fence")) { //System.out.println("fence! @ " + entity); return true; //if (nameToCheck.equals("tile.torch") || nameToCheck.equals("tile.lightgem") || nameToCheck.equals("tile.redstoneLight") || nameToCheck.equals("tile.litpumpkin")) { return true; } } } } } } return false; }
Example 9
Source File: HGWorldGen.java From HexxitGear with GNU General Public License v3.0 | 5 votes |
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if (HexxitGear.getDimBlacklist().contains(world.provider.dimensionId)) return; if (world.getWorldInfo().getTerrainType().getWorldTypeName().equals("flat")) return; int xMin = chunkX << 4; int zMin = chunkZ << 4; int startX = xMin + random.nextInt(16); int startZ = zMin + random.nextInt(16); int tries = random.nextInt(2); for (int i=0; i < tries; i++) { int x = startX + random.nextInt(8) - random.nextInt(8); int z = startZ + random.nextInt(8) - random.nextInt(8); int y = world.getHeightValue(x, z); if ((world.isAirBlock(x, y, z) || (world.getBlockId(x,y,z) == Block.snow.blockID)) && HexxitGear.hexbiscus.canBlockStay(world, x, y, z)) { if (random.nextInt(50) > 1) continue; world.setBlock(x, y, z, HexxitGear.hexbiscus.blockID, 0, 0); } } }
Example 10
Source File: GoldCrook.java From Ex-Aliquo with MIT License | 4 votes |
@Override public boolean onBlockStartBreak(ItemStack item, int X, int Y, int Z, EntityPlayer player) { World world = player.worldObj; int blockID = world.getBlockId(X,Y,Z); int meta = world.getBlockMetadata(X, Y, Z); boolean validTarget = false; boolean extraDropped = false; Block block = Block.blocksList[blockID]; if (block.isLeaves(null, 0, 0, 0)) { if (!world.isRemote) { if (forestryrefcheck && ModsLoaded.isForestryLoaded) { ForestryLeaves(world, block, meta, X, Y, Z); ForestryLeaves(world, block, meta, X, Y, Z); ForestryLeaves(world, block, meta, X, Y, Z); } if (!extras) { block.dropBlockAsItem(world, X, Y, Z, meta, 0); block.dropBlockAsItem(world, X, Y, Z, meta, 0); block.dropBlockAsItem(world, X, Y, Z, meta, 0); } if (ModData.ALLOW_SILKWORMS && world.rand.nextInt(75) == 0) { world.spawnEntityInWorld(new EntityItem(world, X + 0.5D, Y + 0.5D, Z + 0.5D, new ItemStack(getItem(Info.silkworm), 1, 0))); } } } if (blockID == getIDs(Info.silkleaves)) { if (!world.isRemote) { if (ModData.ALLOW_SILKWORMS && world.rand.nextInt(10) == 0) { world.spawnEntityInWorld(new EntityItem(world, X + 0.5D, Y + 0.5D, Z + 0.5D, new ItemStack(getItem(Info.silkworm), 1, 0))); } } } return false; }
Example 11
Source File: MoCBlockLeaf.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
@Override public void updateTick(World world, int i, int j, int k, Random random) { if(world.isRemote) { return; } int l = world.getBlockMetadata(i, j, k); if((l & 8) != 0 && (l & 4) == 0) { byte byte0 = 4; int i1 = byte0 + 1; byte byte1 = 32; int j1 = byte1 * byte1; int k1 = byte1 / 2; if(adjacentTreeBlocks == null) { adjacentTreeBlocks = new int[byte1 * byte1 * byte1]; } if(world.checkChunksExist(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) { for(int l1 = -byte0; l1 <= byte0; l1++) { for(int k2 = -byte0; k2 <= byte0; k2++) { for(int i3 = -byte0; i3 <= byte0; i3++) { int k3 = world.getBlockId(i + l1, j + k2, k + i3); if(k3 == MoCreatures.mocLog.blockID) ///////Log////////////// { adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = 0; continue; } if(k3 == MoCreatures.mocLeaf.blockID) ///////Leaf/////////// { adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -2; } else { adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -1; } } } } for(int i2 = 1; i2 <= 4; i2++) { for(int l2 = -byte0; l2 <= byte0; l2++) { for(int j3 = -byte0; j3 <= byte0; j3++) { for(int l3 = -byte0; l3 <= byte0; l3++) { if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] != i2 - 1) { continue; } if(adjacentTreeBlocks[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) { adjacentTreeBlocks[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2; } if(adjacentTreeBlocks[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) { adjacentTreeBlocks[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2; } if(adjacentTreeBlocks[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] == -2) { adjacentTreeBlocks[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] = i2; } if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] == -2) { adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] = i2; } if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] == -2) { adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] = i2; } if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] == -2) { adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] = i2; } } } } } } int j2 = adjacentTreeBlocks[k1 * j1 + k1 * byte1 + k1]; if(j2 >= 0) { world.setBlockMetadataWithNotify(i, j, k, l & -9, 3); } else { removeLeaves(world, i, j, k); } } }
Example 12
Source File: MoCWorldGenPortal.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
public boolean generate(World world, Random random, int x, int y, int z) { //System.out.println("Generating Portal @ x = "+ x + " y = "+y + " z = "+z + " server = " + MoCreatures.isServer()); if(world.getBlockId(x, y , z) == centerBlockID || world.getBlockId(x, y-1 , z) == centerBlockID || world.getBlockId(x, y+1 , z) == centerBlockID) { //System.out.println("portal already exists"); return true; } if(world.getBlockId(x, y , z) == 0 || world.getBlockId(x, y+1, z) !=0) { return false; } int origX = x; int origY = y; int origZ = z; //cleans the area /*for (int i = x-4; i < x+4; i++) { for (int j = z - 4; j < z + 4 ; j++) { for (int k = y - 1; k < y + 2; k++) { world.setBlock(i, k, j, 2, 0, 0); } } }*/ stairMetadata = 2; for (int nZ = z-3; nZ < z+3; nZ = nZ+5) { for (int nX = x-2; nX < x+2; nX++) { if (nZ > z) { stairMetadata = 3; } world.setBlock(nX, y+1, nZ, stairBlockID, stairMetadata, 2); //System.out.println("stairMetadata = " + stairMetadata); //stairMetadata++; } } for (int nX = x-2; nX < x+2; nX++) { for (int nZ = z-2; nZ < z+2; nZ++) { world.setBlock(nX, y+1, nZ, wallBlockID, wallMetadata, 2); } } for (int nX = x-1; nX < x+1; nX++) { for (int nZ = z-1; nZ < z+1; nZ++) { world.setBlock(nX, y+1, nZ, centerBlockID, centerMetadata, 2); } } for (int j = x-3; j <x+3; j = j+5) { for (int nZ = z-3; nZ < z+3; nZ++) { world.setBlock(j, y+6, nZ, wallBlockID, wallMetadata, 2); } } generatePillar(world, x-3, y, z-3); generatePillar(world, x-3, y, z+2); generatePillar(world, x+2, y, z-3); generatePillar(world, x+2, y, z+2); //System.out.println("portal generated"); return true; }
Example 13
Source File: WorldGenTower.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
public boolean generate(World world, Random random, int x, int y, int z) { int t = 3; if(world.getBlockId(x, y-1 , z) != 0) { for (int i = 0; i < 9; i++) { if(world.getBlockId(x+4-i, y-1, z) == 0) { return false; } } //System.out.println("Generating Tower @ x = "+ x + " y = "+y + " z = "+z); for (int Ny = y-3; Ny < y+21; Ny++) { for (int Nz = z-5; Nz < z+6; Nz = Nz + 10) { for (int Nx = x-2; Nx < x+3; Nx++) { world.setBlock(Nx, Ny, Nz, MainBlockID, MainMetadata, t); } } world.setBlock(x-3, Ny, z-4, MainBlockID, MainMetadata, t); world.setBlock(x+3, Ny, z-4, MainBlockID, MainMetadata, t); world.setBlock(x-4, Ny, z-3, MainBlockID, MainMetadata, t); world.setBlock(x+4, Ny, z-3, MainBlockID, MainMetadata, t); world.setBlock(x-3, Ny, z+4, MainBlockID, MainMetadata, t); world.setBlock(x+3, Ny, z+4, MainBlockID, MainMetadata, t); world.setBlock(x-4, Ny, z+3, MainBlockID, MainMetadata, t); world.setBlock(x+4, Ny, z+3, MainBlockID, MainMetadata, t); for (int Nx = x-5; Nx < x+6; Nx = Nx + 10) { for (int Nz = z-2; Nz < z+3; Nz++) { world.setBlock(Nx, Ny, Nz, MainBlockID, MainMetadata, t); } } } for (int Nx = x-3; Nx < x+4; Nx++) { for (int Nz = z-3; Nz < z+4; Nz++) { world.setBlock(Nx, y-1, Nz, Block.lavaMoving.blockID, 0, t); } } for (int Ny = y; Ny <y+24; Ny = Ny + 8) { world.setBlock(x-1, Ny, z-4, brickBlockID, MainMetadata, t); world.setBlock(x-2, Ny, z-4, brickBlockID, MainMetadata, t); world.setBlock(x-4, Ny+1, z-1, brickBlockID, MainMetadata, t); world.setBlock(x-4, Ny+1, z-2, brickBlockID, MainMetadata, t); world.setBlock(x-4, Ny+2, z+1, brickBlockID, MainMetadata, t); world.setBlock(x-4, Ny+2, z+2, brickBlockID, MainMetadata, t); world.setBlock(x-2, Ny+3, z+4, brickBlockID, MainMetadata, t); world.setBlock(x-1, Ny+3, z+4, brickBlockID, MainMetadata, t); world.setBlock(x+1, Ny+4, z+4, brickBlockID, MainMetadata, t); world.setBlock(x+2, Ny+4, z+4, brickBlockID, MainMetadata, t); world.setBlock(x+4, Ny+5, z+2, brickBlockID, MainMetadata, t); world.setBlock(x+4, Ny+5, z+1, brickBlockID, MainMetadata, t); world.setBlock(x+4, Ny+6, z-1, brickBlockID, MainMetadata, t); world.setBlock(x+4, Ny+6, z-2, brickBlockID, MainMetadata, t); world.setBlock(x+2, Ny+7, z-4, brickBlockID, MainMetadata, t); world.setBlock(x+1, Ny+7, z-4, brickBlockID, MainMetadata, t); /*world.setBlock(x-1, Ny, z-3, brickBlockID, MainMetadata, t); world.setBlock(x-2, Ny, z-3, brickBlockID, MainMetadata, t); world.setBlock(x-3, Ny+1, z-1, brickBlockID, MainMetadata, t); world.setBlock(x-3, Ny+1, z-2, brickBlockID, MainMetadata, t); world.setBlock(x-3, Ny+2, z+1, brickBlockID, MainMetadata, t); world.setBlock(x-3, Ny+2, z+2, brickBlockID, MainMetadata, t); world.setBlock(x-2, Ny+3, z+3, brickBlockID, MainMetadata, t); world.setBlock(x-1, Ny+3, z+3, brickBlockID, MainMetadata, t); world.setBlock(x+1, Ny+4, z+3, brickBlockID, MainMetadata, t); world.setBlock(x+2, Ny+4, z+3, brickBlockID, MainMetadata, t); world.setBlock(x+3, Ny+5, z+2, brickBlockID, MainMetadata, t); world.setBlock(x+3, Ny+5, z+1, brickBlockID, MainMetadata, t); world.setBlock(x+3, Ny+6, z-1, brickBlockID, MainMetadata, t); world.setBlock(x+3, Ny+6, z-2, brickBlockID, MainMetadata, t); world.setBlock(x+2, Ny+7, z-3, brickBlockID, MainMetadata, t); world.setBlock(x+1, Ny+7, z-3, brickBlockID, MainMetadata, t);*/ } return true; } return false; }