Java Code Examples for net.minecraft.world.World#getBlockMetadata()
The following examples show how to use
net.minecraft.world.World#getBlockMetadata() .
These examples are extracted from open source projects.
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 Project: reactor_simulator File: MultiblockTurbineSimulator.java License: MIT License | 6 votes |
@Override protected void isBlockGoodForInterior(World world, int x, int y, int z) throws MultiblockValidationException { // We only allow air and functional parts in turbines. // Air is ok if (world.isAirBlock(x, y, z)) { return; } Block block = world.getBlock(x, y, z); int metadata = world.getBlockMetadata(x, y, z); // Coil windings below here: // Everything else, gtfo throw new MultiblockValidationException(String.format("%d, %d, %d is invalid for a turbine interior. Only rotor parts, metal blocks and empty space are allowed.", x, y, z)); }
Example 2
Source Project: PneumaticCraft File: BlockCreeperPlant.java License: GNU General Public License v3.0 | 6 votes |
@Override public void executeFullGrownEffect(World world, int x, int y, int z, Random rand){ if(world.getBlockMetadata(x, y, z) == 14) { if(!world.isRemote) { world.createExplosion(null, x + 0.5D, y + 0.5D, z + 0.5D, 0.5F, false); EntityItem item = new EntityItem(world, x + 0.5D, y + 0.5D, z + 0.5D, new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.CREEPER_PLANT_DAMAGE)); item.motionX = (rand.nextGaussian() - 0.5D) / 2; item.motionY = rand.nextDouble(); item.motionZ = (rand.nextGaussian() - 0.5D) / 2; item.lifespan = 300; ItemPlasticPlants.markInactive(item); world.spawnEntityInWorld(item); world.setBlock(x, y, z, this, world.getBlockMetadata(x, y, z) - 2, 3); } } else { world.setBlockMetadataWithNotify(x, y, z, 14, 3); NetworkHandler.sendToAllAround(new PacketPlaySound("creeper.primed", x + 0.5D, y + 0.5D, z + 0.5D, 1.0F, 1.0F, true), world); world.scheduleBlockUpdate(x, y, z, this, 60); } }
Example 3
Source Project: mocreaturesdev File: MoCBlockLeaf.java License: 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 Project: GardenCollection File: ItemLatticeMetal.java License: MIT License | 6 votes |
@Override public boolean onItemUse (ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); if (block instanceof BlockCauldron && side == 1 && itemStack.getItemDamage() == 0) { int waterLevel = BlockCauldron.func_150027_b(meta); if (waterLevel == 0) return false; ItemStack newItem = new ItemStack(ModBlocks.latticeMetal, 1, 1); itemStack.stackSize--; EntityItem itemEntity = new EntityItem(world, x + .5, y + 1.5, z + .5, newItem); itemEntity.playSound("random.splash", 0.25F, 1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.4F); world.spawnEntityInWorld(itemEntity); return true; } return super.onItemUse(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ); }
Example 5
Source Project: PneumaticCraft File: BlockSlimePlant.java License: GNU General Public License v3.0 | 6 votes |
@Override public void executeFullGrownEffect(World world, int x, int y, int z, Random rand){ if(world.getBlockMetadata(x, y, z) == 14) { int nearbyEntityCount = world.getEntitiesWithinAABB(EntitySlime.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(SPAWN_RANGE * 2, 4.0D, SPAWN_RANGE * 2)).size(); if(nearbyEntityCount < MAX_NEARBY_ENTITIES) { EntitySlime SS = new EntitySlime(world); double randXmotion = rand.nextDouble() - 0.5D; double randYmotion = 1D;// rand.nextDouble(); double randZmotion = rand.nextDouble() - 0.5D; SS.setLocationAndAngles(x + 0.5D, y + 0.5D, z + 0.5D, rand.nextFloat() * 360.0F, 0.0F); SS.motionX = randXmotion; SS.motionY = randYmotion; SS.motionZ = randZmotion; world.spawnEntityInWorld(SS); SS.spawnExplosionParticle(); SS.playSound("mob.newsound.chickenplop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); world.setBlockMetadataWithNotify(x, y, z, 13 - SS.getSlimeSize(), 3); } } else { world.setBlockMetadataWithNotify(x, y, z, 14, 2); world.scheduleBlockUpdate(x, y, z, this, 60); } }
Example 6
Source Project: Ex-Aliquo File: BlockEndCake.java License: MIT License | 5 votes |
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { int meta = world.getBlockMetadata(x, y, z) - 1; ItemStack item = player.getCurrentEquippedItem(); if (player.capabilities.isCreativeMode) { if (item != null && item.getItem() == Item.eyeOfEnder) { world.setBlockMetadataWithNotify(x, y, z, 0, 2); return true; } else { player.travelToDimension(1); return true; } } else { if (item != null && item.getItem() == Item.eyeOfEnder) { if (meta > 0) { world.setBlockMetadataWithNotify(x, y, z, meta, 2); --item.stackSize; return true; } } else { nomEndCake(world, x, y, z, player); return true; } } return false; }
Example 7
Source Project: Chisel-2 File: BlockSnakestone.java License: GNU General Public License v2.0 | 5 votes |
public boolean rotateBodyPart(World world, int x, int y, int z) { int[] con = getConnections(world, x, y, z); int blockMeta = world.getBlockMetadata(x, y, z); int kind = blockMeta & 0xc; if (con[1] == -1) return false; if (con[2] != -1) return false; int meta = 15; if (con[0] == 2 && con[1] == 3) { meta = 12; } else if (con[0] == 0 && con[1] == 1) { meta = 13; } else if (con[0] == 4 && con[1] == 5) { meta = 14; } else if (con[1] == 4) { meta = SEC_DOWN | con[0]; } else if (con[1] == 5) { meta = SEC_UP | con[0]; } if (blockMeta != meta) world.setBlockMetadataWithNotify(x, y, z, meta, 3); return true; }
Example 8
Source Project: Gadomancy File: BlockAuraPylon.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) { if(world.getBlockMetadata(x, y, z) != 1) { Block up = world.getBlock(x, y + 1, z); return up != null && up instanceof BlockAuraPylon && up.onBlockActivated(world, x, y + 1, z, player, side, par7, par8, par9); } ItemStack heldItem = player.getHeldItem(); if(!world.isRemote && heldItem != null && heldItem.getItem() instanceof ItemWandCasting && ResearchManager.isResearchComplete(player.getCommandSenderName(), Gadomancy.MODID.toUpperCase() + ".AURA_PYLON")) { TileAuraPylon tileAuraPylon = (TileAuraPylon) world.getTileEntity(x, y - 1, z); if(MultiblockHelper.isMultiblockPresent(world, x, y, z, RegisteredMultiblocks.auraPylonPattern) && !tileAuraPylon.isPartOfMultiblock() && ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsAuraPylonMultiblock, true)) { PacketStartAnimation pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, x, y, z); NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32); PacketHandler.INSTANCE.sendToAllAround(pkt, point); TileAuraPylon ta = (TileAuraPylon) world.getTileEntity(x, y - 1, z); ta.setTileInformation(true, false); ta = (TileAuraPylon) world.getTileEntity(x, y - 3, z); ta.setTileInformation(false, true); int count = 1; TileEntity iter = world.getTileEntity(x, y - count, z); while(iter != null && iter instanceof TileAuraPylon) { ((TileAuraPylon) iter).setPartOfMultiblock(true); world.markBlockForUpdate(x, y - count, z); iter.markDirty(); pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, x, y - count, z); PacketHandler.INSTANCE.sendToAllAround(pkt, point); count++; iter = world.getTileEntity(x, y - count, z); } } } return false; }
Example 9
Source Project: archimedes-ships File: EntityShip.java License: MIT License | 5 votes |
public static boolean isAABBInLiquidNotFall(World world, AxisAlignedBB aabb) { int i = MathHelper.floor_double(aabb.minX); int j = MathHelper.floor_double(aabb.maxX + 1D); int k = MathHelper.floor_double(aabb.minY); int l = MathHelper.floor_double(aabb.maxY + 1D); int i1 = MathHelper.floor_double(aabb.minZ); int j1 = MathHelper.floor_double(aabb.maxZ + 1D); for (int x = i; x < j; ++x) { for (int y = k; y < l; ++y) { for (int z = i1; z < j1; ++z) { Block block = world.getBlock(x, y, z); if (block != null && (block.getMaterial() == Material.water || block.getMaterial() == Material.lava)) { int j2 = world.getBlockMetadata(x, y, z); double d0 = y + 1; if (j2 < 8) { d0 = y + 1 - j2 / 8.0D; if (d0 >= aabb.minY) { return true; } } } } } } return false; }
Example 10
Source Project: ForbiddenMagic File: BlockArcaneCake.java License: Do What The F*ck You Want To Public License | 5 votes |
@Override public void updateTick(World world, int x, int y, int z, Random par5Random) { super.updateTick(world, x, y, z, par5Random); int l = world.getBlockMetadata(x, y, z); if (l > 0) { // if (par5Random.nextInt((int)(25.0F / f) + 1) == 0) // { --l; world.setBlockMetadataWithNotify(x, y, z, l, 2); // } } }
Example 11
Source Project: Chisel File: ItemMarbleSlab.java License: GNU General Public License v2.0 | 5 votes |
@Override public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack) { BlockMarbleSlab block = (BlockMarbleSlab) Block.getBlockFromItem(this); switch(side) { case 0: --y; break; case 1: ++y; break; case 2: --z; break; case 3: ++z; break; case 4: --x; break; case 5: ++x; break; } Block targetBlock = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); return (targetBlock.equals(block) || targetBlock.equals(block.top)) && meta == stack.getItemDamage() || world.canPlaceEntityOnSide(block, x, y, z, false, side, (Entity) null, stack); }
Example 12
Source Project: Artifacts File: BlockWallPlate.java License: MIT License | 5 votes |
@Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { int meta = world.getBlockMetadata(x, y, z) & 0x07; boolean flag = false; if (meta == 2 && world.isSideSolid(x, y, z+1, NORTH)) { flag = true; } if (meta == 3 && world.isSideSolid(x, y, z-1, SOUTH)) { flag = true; } if (meta == 4 && world.isSideSolid(x+1, y, z, WEST)) { flag = true; } if (meta == 5 && world.isSideSolid(x-1, y, z, EAST)) { flag = true; } if (!flag) { //System.out.println("Wall plate is invalid! Side is :" + meta); this.dropBlockAsItem(world, x, y, z, meta, 0); world.setBlockToAir(x, y, z); } //super.onNeighborBlockChange(par1World, par2, par3, par4, par5); }
Example 13
Source Project: Chisel-2 File: BlockSnakestone.java License: GNU General Public License v2.0 | 5 votes |
@Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { int kind = world.getBlockMetadata(x, y, z) & 0xC; if (kind == 0) { rotateHead(world, x, y, z); } else { rotateBodyPart(world, x, y, z); } }
Example 14
Source Project: Gadomancy File: BlockStoneMachine.java License: GNU Lesser General Public License v3.0 | 5 votes |
@Override public int getComparatorInputOverride(World world, int x, int y, int z, int side) { int metadata = world.getBlockMetadata(x, y, z); if(metadata == 2) { TileBlockProtector protector = (TileBlockProtector) world.getTileEntity(x, y, z); return protector.getCurrentRange(); } return 0; }
Example 15
Source Project: PneumaticCraft File: HackableLever.java License: GNU General Public License v3.0 | 5 votes |
@Override public void addPostHackInfo(World world, int x, int y, int z, List<String> curInfo, EntityPlayer player){ if((world.getBlockMetadata(x, y, z) & 8) == 0) { curInfo.add("pneumaticHelmet.hacking.finished.deactivated"); } else { curInfo.add("pneumaticHelmet.hacking.finished.activated"); } }
Example 16
Source Project: ForbiddenMagic File: BlockArcaneCake.java License: Do What The F*ck You Want To Public License | 5 votes |
@SideOnly(Side.CLIENT) @Override public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { int l = world.getBlockMetadata(x, y, z); float f = 0.0625F; float f1 = (float) (1 + l) / 12.0F; float f2 = 0.5F; //return AxisAlignedBB.getAABBPool().getAABB((double) ((float) x + f1), (double) y, (double) ((float) z + f), (double) ((float) (x + 1) - f), (double) ((float) y + f2), (double) ((float) (z + 1) - f)); return AxisAlignedBB.getBoundingBox((double)((float)x + f1), (double)y, (double)((float)z + f), (double)((float)(x + 1) - f), (double)((float)y + f2), (double)((float)(z + 1) - f)); }
Example 17
Source Project: ForbiddenMagic File: ItemMorphPickaxe.java License: Do What The F*ck You Want To Public License | 5 votes |
@Override public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase player) { if(EnchantmentHelper.getEnchantmentLevel(DarkEnchantments.impact.effectId, stack) <= 0) return super.onBlockDestroyed(stack, world, block, x, y, z, player); if(!player.worldObj.isRemote) { int meta = world.getBlockMetadata(x, y, z); if(ForgeHooks.isToolEffective(stack, block, meta)) { for(int aa = -1; aa <= 1; ++aa) { for(int bb = -1; bb <= 1; ++bb) { int xx = 0; int yy = 0; int zz = 0; if(this.side <= 1) { xx = aa; zz = bb; } else if(this.side <= 3) { xx = aa; yy = bb; } else { zz = aa; yy = bb; } if(!(player instanceof EntityPlayer) || world.canMineBlock((EntityPlayer)player, x + xx, y + yy, z + zz)) { Block bl = world.getBlock(x + xx, y + yy, z + zz); meta = world.getBlockMetadata(x + xx, y + yy, z + zz); if(bl.getBlockHardness(world, x + xx, y + yy, z + zz) >= 0.0F && ForgeHooks.isToolEffective(stack, bl, meta)) { stack.damageItem(1, player); BlockUtils.harvestBlock(world, (EntityPlayer)player, x + xx, y + yy, z + zz, true, 2); } } } } } else return super.onBlockDestroyed(stack, world, block, x, y, z, player); } return super.onBlockDestroyed(stack, world, block, x, y, z, player); }
Example 18
Source Project: GardenCollection File: BlockSmallFire.java License: MIT License | 4 votes |
private static boolean blockCanHostSmallFlame (World world, int x, int y, int z) { Block block = world.getBlock(x, y, z); int metadata = world.getBlockMetadata(x, y, z); return GardenCoreAPI.instance().blockCanHostSmallFlame(block, metadata); }
Example 19
Source Project: PneumaticCraft File: BlockSlimePlant.java License: GNU General Public License v3.0 | 4 votes |
@Override public boolean skipGrowthCheck(World world, int x, int y, int z){ return world.getBlockMetadata(x, y, z) == 14; }
Example 20
Source Project: GardenCollection File: BlockThinLog.java License: MIT License | 4 votes |
@SideOnly(Side.CLIENT) @Override public boolean addHitEffects (World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) { TileEntityWoodProxy te = getTileEntity(worldObj, target.blockX, target.blockY, target.blockZ); BlockThinLog block = getBlock(worldObj, target.blockX, target.blockY, target.blockZ); if (te == null || block == null) return false; int protoMeta = te.getProtoMeta(); Block protoBlock = te.getProtoBlock(); if (protoBlock == null) { protoBlock = Blocks.log; protoMeta = worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ); } float f = 0.1F; double xPos = target.blockX + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (f * 2.0F)) + f + block.getBlockBoundsMinX(); double yPos = target.blockY + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (f * 2.0F)) + f + block.getBlockBoundsMinY(); double zPos = target.blockZ + worldObj.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (f * 2.0F)) + f + block.getBlockBoundsMinZ(); if (target.sideHit == 0) yPos = target.blockY + block.getBlockBoundsMinY() - f; if (target.sideHit == 1) yPos = target.blockY + block.getBlockBoundsMaxY() + f; if (target.sideHit == 2) zPos = target.blockZ + block.getBlockBoundsMinZ() - f; if (target.sideHit == 3) zPos = target.blockZ + block.getBlockBoundsMaxZ() + f; if (target.sideHit == 4) xPos = target.blockX + block.getBlockBoundsMinX() - f; if (target.sideHit == 5) xPos = target.blockX + block.getBlockBoundsMaxX() + f; EntityDiggingFX fx = new EntityDiggingFX(worldObj, xPos, yPos, zPos, 0.0D, 0.0D, 0.0D, block, worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ)); fx.applyColourMultiplier(target.blockX, target.blockY, target.blockZ); fx.multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F); fx.setParticleIcon(block.getIcon(worldObj.rand.nextInt(6), te.composeMetadata(protoBlock, protoMeta))); effectRenderer.addEffect(fx); return true; }