Java Code Examples for net.minecraft.world.World#setBlockMetadataWithNotify()
The following examples show how to use
net.minecraft.world.World#setBlockMetadataWithNotify() .
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: BW_TileEntityContainer_Multiple.java From bartworks with MIT License | 6 votes |
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) { TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof IWrenchable && itemStack != null) { IWrenchable tile2 = (IWrenchable) tile; int meta = itemStack.getItemDamage(); world.setBlockMetadataWithNotify(x, y, z, meta, 2); if (entity != null) { int face = MathHelper.floor_double(entity.rotationYaw * 4.0f / 360.0f + 0.5) & 0x3; switch (face) { case 0: tile2.setFacing((short) 2); break; case 1: tile2.setFacing((short) 5); break; case 2: tile2.setFacing((short) 3); break; case 3: tile2.setFacing((short) 4); break; } } } }
Example 2
Source File: BlockQuickSand.java From Artifacts with MIT License | 6 votes |
private boolean flowSideways(World world, int x, int y, int z, int xOffset, int zOffset) { if(world.getBlock(x, y, z) == BlockQuickSand.instance) { //A bit viscous; won't flow into an adjacent quicksand block unless its quicksand level is at least 2 less. if(world.getBlockMetadata(x, y, z) < 15 && (world.isAirBlock(x + xOffset, y, z + zOffset) || (world.getBlock(x + xOffset, y, z + zOffset) == BlockQuickSand.instance && getQuicksandLevel(world, x, y, z) > getQuicksandLevel(world, x + xOffset, y, z + zOffset) + 2))) { //Only flow one piece of the block sideways, in the given direction. int sandAmount = getQuicksandLevel(world, x, y, z); int amountFlowed = flowIntoBlock(world, x+xOffset, y, z+zOffset, 1); if(amountFlowed > 0) { if(sandAmount <= amountFlowed) { world.setBlockToAir(x, y, z); return true; //This should never happen! But it's here just in case. } else { world.setBlockMetadataWithNotify(x, y, z, 16 - (sandAmount - amountFlowed), 3); return true; } } } } return false; }
Example 3
Source File: BlockBloomeryFurnace.java From GardenCollection with MIT License | 6 votes |
@Override public void onBlockAdded (World world, int x, int y, int z) { super.onBlockAdded(world, x, y, z); if (!world.isRemote) { Block neighborZN = world.getBlock(x, y, z - 1); Block neighborZP = world.getBlock(x, y, z + 1); Block neighborXN = world.getBlock(x - 1, y, z); Block neighborXP = world.getBlock(x + 1, y, z); byte direction = 3; if (neighborZP.func_149730_j() && !neighborZN.func_149730_j()) direction = 3; if (neighborZN.func_149730_j() && !neighborZP.func_149730_j()) direction = 2; if (neighborXP.func_149730_j() && !neighborXN.func_149730_j()) direction = 5; if (neighborXN.func_149730_j() && !neighborXP.func_149730_j()) direction = 4; world.setBlockMetadataWithNotify(x, y, z, direction, 2); } }
Example 4
Source File: BlockSnakestone.java From Chisel-2 with GNU General Public License v2.0 | 6 votes |
@Override public int onBlockPlaced(World world, int x, int y, int z, int side, float hx, float hy, float hz, int meta) { if (meta <= 3) return meta; if (rotateBodyPart(world, x, y, z)) { return world.getBlockMetadata(x, y, z); } if (side == 0 || side == 1) meta = 14; if (side == 2 || side == 3) meta = 13; if (side == 4 || side == 5) meta = 12; world.setBlockMetadataWithNotify(x, y, z, meta, 2); return meta; }
Example 5
Source File: BlockPotteryTable.java From GardenCollection with MIT License | 6 votes |
private void setBlockDirection (World world, int x, int y, int z) { if (!world.isRemote) { Block blockZNeg = world.getBlock(x, y, z - 1); Block blockZPos = world.getBlock(x, y, z + 1); Block blockXNeg = world.getBlock(x - 1, y, z); Block blockXPos = world.getBlock(x + 1, y, z); byte dir = 3; if (blockZNeg.func_149730_j() && !blockZPos.func_149730_j()) dir = 3; if (blockZPos.func_149730_j() && !blockZNeg.func_149730_j()) dir = 2; if (blockXNeg.func_149730_j() && !blockXPos.func_149730_j()) dir = 5; if (blockXPos.func_149730_j() && !blockXNeg.func_149730_j()) dir = 4; world.setBlockMetadataWithNotify(x, y, z, dir, 2); } }
Example 6
Source File: BlockPneumaticDoor.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection face){ int meta = world.getBlockMetadata(x, y, z); if(meta < 6) { super.rotateBlock(world, player, x, y, z, face); world.setBlockMetadataWithNotify(x, y + 1, z, world.getBlockMetadata(x, y, z) + 6, 3); TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntityPneumaticDoor) { ((TileEntityPneumaticDoor)te).rightGoing = true; ((TileEntityPneumaticDoor)te).setRotation(0); TileEntity topDoor = world.getTileEntity(x, y + 1, z); if(topDoor instanceof TileEntityPneumaticDoor) { ((TileEntityPneumaticDoor)topDoor).sendDescriptionPacket(); } } } else { return rotateBlock(world, player, x, y - 1, z, face); } return true; }
Example 7
Source File: BlockQuickSand.java From Artifacts with MIT License | 6 votes |
private boolean flowDown(World world, int x, int y, int z) { if(world.getBlock(x, y, z) == BlockQuickSand.instance) { //Flow the entire block downwards, or as much as possible. int sandAmount = getQuicksandLevel(world, x, y, z); int amountFlowed = flowIntoBlock(world, x, y-1, z, sandAmount); if(amountFlowed > 0) { if(sandAmount <= amountFlowed) { world.setBlockToAir(x, y, z); return true; } else { world.setBlockMetadataWithNotify(x, y, z, 16 - (sandAmount - amountFlowed), 3); return true; } } } return false; }
Example 8
Source File: BlockSquidPlant.java From PneumaticCraft with 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(EntitySquid.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) { EntitySquid squid = new EntitySquid(world); double randXmotion = rand.nextDouble() - 0.5D; double randYmotion = 1D;// rand.nextDouble(); double randZmotion = rand.nextDouble() - 0.5D; squid.setLocationAndAngles(x + 0.5D, y + 0.5D, z + 0.5D, rand.nextFloat() * 360.0F, 0.0F); squid.motionX = randXmotion; squid.motionY = randYmotion; squid.motionZ = randZmotion; world.spawnEntityInWorld(squid); squid.spawnExplosionParticle(); squid.playSound("mob.newsound.chickenplop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); world.setBlockMetadataWithNotify(x, y, z, 11, 3); } } else { world.setBlockMetadataWithNotify(x, y, z, 14, 2); world.scheduleBlockUpdate(x, y, z, this, 60); } }
Example 9
Source File: BW_TileEntityContainer.java From bartworks with MIT License | 6 votes |
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) { TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof IWrenchable && itemStack != null) { IWrenchable tile2 = (IWrenchable) tile; int meta = itemStack.getItemDamage(); world.setBlockMetadataWithNotify(x, y, z, meta, 2); if (entity != null) { int face = MathHelper.floor_double(entity.rotationYaw * 4.0f / 360.0f + 0.5) & 0x3; switch (face) { case 0: tile2.setFacing((short) 2); break; case 1: tile2.setFacing((short) 5); break; case 2: tile2.setFacing((short) 3); break; case 3: tile2.setFacing((short) 4); break; } } } }
Example 10
Source File: RotatableColorBlock.java From ExtraCells1 with MIT License | 5 votes |
@Override public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) { ForgeDirection rotation = ForgeDirection.getOrientation(worldObj.getBlockMetadata(x, y, z)); worldObj.setBlockMetadataWithNotify(x, y, z, rotateDirecions(rotation).ordinal(), 3); TileEntity te = worldObj.getBlockTileEntity(x, y, z); if (te instanceof IGridTileEntity) { MinecraftForge.EVENT_BUS.post(new GridTileConnectivityEvent((IGridTileEntity) te, worldObj, new WorldCoord(x, y, z))); } return true; }
Example 11
Source File: BlockPressureChamberInterface.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection side){ if(player.isSneaking()) { return super.rotateBlock(world, player, x, y, z, side); } else { int newMeta = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)).getRotation(side).ordinal(); world.setBlockMetadataWithNotify(x, y, z, newMeta, 3); return true; } }
Example 12
Source File: BlockLaserBeamSource.java From Artifacts with MIT License | 5 votes |
@Override public void updateTick(World world, int x, int y, int z, Random rand) { int meta = world.getBlockMetadata(x, y, z); this.updateLaserState(world, x, y, z, this.instance, meta, true, -1, 0); if((meta&8) == 8) { world.setBlockMetadataWithNotify(x, y, z, meta&3, 3); notifyNeighborOfChange(world, x, y, z, meta&3); world.scheduleBlockUpdate(x, y, z, this.instance, this.tickRate(world)); } }
Example 13
Source File: BlockChopperPlant.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void executeFullGrownEffect(World world, int x, int y, int z, Random rand){ if(!world.isRemote) { EntityChopperSeeds plant = new EntityChopperSeeds(world, x + 0.5D, y + 0.8D, z + 0.5D); // plant.motionX = (rand.nextFloat() - 0.5F); plant.motionY = 0.3F; // plant.motionZ = (rand.nextFloat() - 0.5F); world.spawnEntityInWorld(plant); plant.playSound("mob.newsound.chickenplop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 2, 3); } }
Example 14
Source File: BlockSnakestone.java From Chisel-2 with 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 15
Source File: BlockEnderPlant.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void executeFullGrownEffect(World world, int x, int y, int z, Random rand){ if(!world.isRemote) { for(int i = 0; i < 50; i++) { int randX = x + rand.nextInt(30) - 15; int randY = y + rand.nextInt(8); int randZ = z + rand.nextInt(30) - 15; Block block = world.getBlock(randX, randY, randZ); if(!block.getMaterial().blocksMovement()) { ItemStack seed = new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.ENDER_PLANT_DAMAGE); EntityItem plant = new EntityItem(world, randX + 0.5D, randY + 0.5D, randZ + 0.5D, seed); // plant.motionX = plant.motionY = plant.motionZ = 0; plant.lifespan = 300; ItemPlasticPlants.markInactive(plant); world.spawnEntityInWorld(plant); plant.playSound("mob.endermen.portal", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); short short1 = 128; for(int j = 0; j < short1; ++j) { double d6 = j / (short1 - 1.0D); float f = (rand.nextFloat() - 0.5F) * 0.2F; float f1 = (rand.nextFloat() - 0.5F) * 0.2F; float f2 = (rand.nextFloat() - 0.5F) * 0.2F; double d7 = x + 0.5D + (plant.posX - (x + 0.5D)) * d6 + (rand.nextDouble() - 0.5D); double d8 = y + 0.5D + (plant.posY - (y + 0.5D)) * d6 + rand.nextDouble(); double d9 = z + 0.5D + (plant.posZ - (z + 0.5D)) * d6 + (rand.nextDouble() - 0.5D); NetworkHandler.sendToAllAround(new PacketSpawnParticle("portal", d7, d8, d9, f, f1, f2), world); } world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 2, 3); break; } } } }
Example 16
Source File: BlockTrap.java From Artifacts with MIT License | 5 votes |
/** * Called when the block is placed in the world. */ @Override public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) { int l = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLiving); par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2); if (par6ItemStack.hasDisplayName()) { ((TileEntityDispenser)par1World.getTileEntity(par2, par3, par4)).func_146018_a/*setCustomName*/(par6ItemStack.getDisplayName()); } }
Example 17
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 18
Source File: ItemMossPaste.java From GardenCollection with MIT License | 4 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); Block newBlock = null; int newMeta = -1; if (block == Blocks.stonebrick) { if (meta == 0) newMeta = 1; else if (meta == 1) { newBlock = ModBlocks.mossBrick; newMeta = 0; } else if (meta == 2) { newBlock = ModBlocks.mossBrick; newMeta = 3; } } else if (block == ModBlocks.mossBrick) { if (meta == 0) newMeta = 1; if (meta == 1) newMeta = 2; if (meta == 3) newMeta = 4; if (meta == 4) newMeta = 5; if (meta == 5) newMeta = 6; } else if (block == Blocks.cobblestone) { if (meta == 0) { newBlock = Blocks.mossy_cobblestone; newMeta = 0; } } if (newBlock != null) { world.setBlock(x, y, z, newBlock); } if (newMeta != -1) { world.setBlockMetadataWithNotify(x, y, z, newMeta, 3); itemStack.damageItem(1, player); return true; } return super.onItemUse(itemStack, player, world, x, y, z, side, hitX, hitY, hitZ); }
Example 19
Source File: BlockLaserBeamSource.java From Artifacts with MIT License | 4 votes |
public void updateLaserState(World world, int x, int y, int z, Block block, int meta, boolean triggered, int par8, int par9) { int l1 = meta & 3; boolean flag1 = (meta & 8) == 8; //boolean flag2 = (meta & 8) == 8; //boolean isThis = id == this.blockID; //boolean flag4 = false; //boolean solidTop = !world.isBlockSolidOnSide(x, y - 1, z, UP); int offsetX = Direction.offsetX[l1]; int offsetZ = Direction.offsetZ[l1]; //int k2 = 0; //int[] aint = new int[42]; int l2; int i3; Block j3; int k3; //int l3; boolean shouldbetriggered = false; boolean quitEarly = false; for (i3 = 1; i3 < 16; ++i3) { l2 = x + offsetX * i3; k3 = z + offsetZ * i3; j3 = world.getBlock(l2, y, k3); if(j3 == Blocks.air || (j3 != BlockLaserBeam.instance && j3.getMaterial() == Material.air)) { if(!quitEarly) world.setBlock(l2, y, k3, BlockLaserBeam.instance, 0, 3); } if(j3 == BlockLaserBeam.instance) { if(quitEarly) { world.setBlockToAir(l2, y, k3); } else if(world.getBlockMetadata(l2, y, k3) != 0) { shouldbetriggered = true; //world.scheduleBlockUpdate(l2, y, k3, blockID, 10); //world.setBlockMetadataWithNotify(l2, y, k3, 0, 3); } } if (world.getBlock(l2, y, k3).isOpaqueCube()) { quitEarly = true; } } if(triggered) { if(shouldbetriggered) { world.setBlockMetadataWithNotify(x, y, z, l1|8, 3); world.scheduleBlockUpdate(x, y, z, this.instance, this.tickRate(world)); notifyNeighborOfChange(world, x, y, z, l1); } } }
Example 20
Source File: BlockLaserBeamSource.java From Artifacts with MIT License | 4 votes |
@Override public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { //System.out.println("Collide"); if (!par1World.isRemote) { /*int m = par1World.getBlockMetadata(par2, par3, par4); if ((m & 8) != 8) { par1World.setBlockMetadataWithNotify(par2, par3, par4, m, 3); }*/ int l = par1World.getBlockMetadata(par2, par3, par4); boolean flag = (l & 8) == 8; boolean flag1 = false; List list = par1World.getEntitiesWithinAABBExcludingEntity((Entity)null, AxisAlignedBB.getBoundingBox((double)par2 + this.minX, (double)par3 + this.minY, (double)par4 + this.minZ, (double)par2 + this.maxX, (double)par3 + this.maxY, (double)par4 + this.maxZ)); if (!list.isEmpty()) { Iterator iterator = list.iterator(); while (iterator.hasNext()) { Entity entity = (Entity)iterator.next(); if (entity instanceof EntityLivingBase && !entity.doesEntityNotTriggerPressurePlate()) { flag1 = true; break; } } } if (flag1 && !flag) { l |= 8; par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 3); notifyNeighborOfChange(par1World, par2, par3, par4, l); //} //if (flag1) //{ par1World.scheduleBlockUpdate(par2, par3, par4, this.instance, this.tickRate(par1World)); } } }