Java Code Examples for net.minecraft.world.World.setBlock()

The following are Jave code examples for showing how to use setBlock() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Technical   File: TechnicalWorldGenerator.java   View Source Code Vote up 6 votes
private void addOreSpawn(Block block, Block target, World world, Random random, int posX, int posZ) {
	int veinSize = 96;
	veinSize += random.nextInt(128);
	int posY = random.nextInt(16 + 64 - (1 + block.getHarvestLevel(0)) * 16);
	if(random.nextInt(25 + block.getHarvestLevel(0) * 5) == 0) {
		new TechnicalWorldGenMinable(block, veinSize, target).generateSparse(world, random, posX, posY, posZ);
	} else {
		for(int i = 0; i < 10; i++) {
			int x = posX + random.nextInt(16);
			int y = random.nextInt(128);
			int z = posZ + random.nextInt(16);
			if(world.getBlock(x, y, z).isReplaceableOreGen(world, x, y, z, target)) {
				world.setBlock(x, y, z, block);
			}
		}
	}
}
 
Example 2
Project: Technical   File: Centrifuge.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if(active)
		world.setBlock(x, y, z, TechnicalBlock.CentrifugeActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.CentrifugeIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if(tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 3
Project: Technical   File: ElectrolyserMedium.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if(active)
		world.setBlock(x, y, z, TechnicalBlock.ElectrolyserMediumActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.ElectrolyserMediumIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if(tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 4
Project: Technical   File: Miner.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if (active)
		world.setBlock(x, y, z, TechnicalBlock.MinerActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.MinerIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if (tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 5
Project: Technical   File: GrinderAdvanced.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if(active)
		world.setBlock(x, y, z, TechnicalBlock.GrinderAdvancedActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.GrinderAdvancedIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if(tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 6
Project: Technical   File: CentrifugeAdvanced.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if(active)
		world.setBlock(x, y, z, TechnicalBlock.CentrifugeAdvancedActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.CentrifugeAdvancedIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if(tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 7
Project: Technical   File: MinerMedium.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if (active)
		world.setBlock(x, y, z, TechnicalBlock.MinerMediumActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.MinerMediumIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if (tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 8
Project: connor41-etfuturum2   File: FrostedIce.java   View Source Code Vote up 6 votes
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
	if (world.isRemote)
		return;

	int surroundingBlockCount = 0;
	for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
		Block block = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
		if (block == this || block == Blocks.ice || block == Blocks.packed_ice)
			if (++surroundingBlockCount >= 4)
				break;
	}

	if (surroundingBlockCount < 4 || rand.nextInt(100) <= 33) {
		int meta = world.getBlockMetadata(x, y, z);
		if (meta < 3)
			world.setBlockMetadataWithNotify(x, y, z, meta + 1, 2);
		else
			world.setBlock(x, y, z, Blocks.water);
	}

	world.scheduleBlockUpdate(x, y, z, this, 40 + rand.nextInt(40));
}
 
Example 9
Project: connor41-etfuturum2   File: ItemGenericSlab.java   View Source Code Vote up 6 votes
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
	if (stack.stackSize == 0)
		return false;
	else if (!player.canPlayerEdit(x, y, z, side, stack))
		return false;
	else {
		Block block = world.getBlock(x, y, z);
		int meta = world.getBlockMetadata(x, y, z);
		boolean flag = meta == 1;

		if (block == field_150939_a && (side == 1 && !flag || side == 0 && flag)) {
			if (world.checkNoEntityCollision(field_150939_a.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlock(x, y, z, field_150939_a, 2, 3)) {
				world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, field_150939_a.stepSound.func_150496_b(), (field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, field_150939_a.stepSound.getPitch() * 0.8F);
				stack.stackSize--;
			}

			return true;
		} else
			return func_150946_a(stack, player, world, x, y, z, side) ? true : super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
	}
}
 
Example 10
Project: Technical   File: Grinder.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if(active)
		world.setBlock(x, y, z, TechnicalBlock.GrinderActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.GrinderIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if(tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 11
Project: Technical   File: TechnicalWorldGenerator.java   View Source Code Vote up 6 votes
private void removeStone(World world, Random random, int x, int z) {
	int id = world.getBiomeGenForCoords(x, z).biomeID;
	Block block = Blocks.stone;

	if(id == 35 || id == 163 || id == 29 || id == 157 || id == 6 || id == 134 || id == 160 || id == 161 || id == 32 || id == 33) {
		block = Granite;
	} else if(id == 36 || id == 164 || id == 16 || id == 14 || id == 15 || id == 0 || id == 24 || id == 26) {
		block = Basalt;
	} else if(id == 2 || id == 1 || id == 7 || id == 129 || id == 5 || id == 30 || id == 11) {
		block = Limestone;
	} else if(id == 130 || id == 17 || id == 21 || id == 149 || id == 23 || id == 151 || id == 22 || id == 133 || id == 155 || id == 19 || id == 31 || id == 158 || id == 27) {
		block = Shale;
	} else if(id == 37 || id == 165 || id == 132 || id == 4 || id == 3 || id == 131 || id == 34 || id == 162 || id == 28 || id == 156 || id == 25) {
		block = Slate;
	} else if(id == 39 || id == 167 || id == 38 || id == 166 || id == 18 || id == 13 || id == 12 || id == 140) {
		block = Gneiss;
	} else {
		FMLLog.log(Level.ERROR, Technical.modName + ": TechnicalWorldGenerator could not find stone type for " + world.getBiomeGenForCoords(x, z).biomeName + " (id " + id + "). Please report this to the mod author(s)");
	}

	for(int y = 0; y < world.getActualHeight(); y++) {
		if(world.getBlock(x, y, z) == Blocks.stone)
			world.setBlock(x, y, z, block, 0, 0);
	}
}
 
Example 12
Project: Technical   File: ElectricFurnaceAdvanced.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if (active)
		world.setBlock(x, y, z, TechnicalBlock.ElectricFurnaceAdvancedActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.ElectricFurnaceAdvancedIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if (tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 13
Project: Technical   File: RepairingForgeAdvanced.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if(active)
		world.setBlock(x, y, z, TechnicalBlock.RepairingForgeAdvancedActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.RepairingForgeAdvancedIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if(tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 14
Project: Technical   File: ElectricFurnaceBasic.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if (active)
		world.setBlock(x, y, z, TechnicalBlock.ElectricFurnaceBasicActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.ElectricFurnaceBasicIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if (tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 15
Project: Technical   File: GrinderMedium.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if(active)
		world.setBlock(x, y, z, TechnicalBlock.GrinderMediumActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.GrinderMediumIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if(tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 16
Project: Technical   File: Washer.java   View Source Code Vote up 6 votes
public static void updateBlockState(boolean active, World world, int x, int y, int z) {
	int direction = world.getBlockMetadata(x, y, z);
	TileEntity tileEntity = world.getTileEntity(x, y, z);
	isBurning = true;

	if(active)
		world.setBlock(x, y, z, TechnicalBlock.WasherActive);
	else
		world.setBlock(x, y, z, TechnicalBlock.WasherIdle);

	isBurning = false;
	world.setBlockMetadataWithNotify(x, y, z, direction, 2);

	if(tileEntity != null) {
		tileEntity.validate();
		world.setTileEntity(x, y, z, tileEntity);
	}
}
 
Example 17
Project: Prospecting   File: BlockIndicatorFlowerDouble.java   View Source Code Vote up 5 votes
@Override
public int onBlockPlaced(World world, int x, int y, int z,  int facing, float offset_x, float offset_y, float offset_z, int meta) {
	if (!isTop(world, x, y, z) && y < 255) {
		world.setBlock(x, y+1, z, this, 1, 1);
		return 0;
	}
	return 1;
}
 
Example 18
Project: connor41-etfuturum2   File: NewAnvil.java   View Source Code Vote up 5 votes
public static void onPlayerInteract(PlayerInteractEvent event) {
	if (!EtFuturum.enableAnvil)
		return;

	World world = event.world;
	int x = event.x;
	int y = event.y;
	int z = event.z;

	if (world == null || world.isRemote)
		return;
	if (world.getBlock(x, y, z) == Blocks.anvil)
		world.setBlock(x, y, z, ModBlocks.anvil, world.getBlockMetadata(x, y, z), 3);
}
 
Example 19
Project: connor41-etfuturum2   File: OceanMonument.java   View Source Code Vote up 4 votes
private static void generatePillarSection(World world, int x, int y, int z, Block block, int meta) {
	for (int i = 0; i < 4; i++)
		for (int k = 0; k < 4; k++)
			if (world.getBlock(x + i, y, z).getBlockHardness(world, x + i, y, z + k) > 0)
				world.setBlock(x + i, y, z + k, block, meta, 2);
}
 
Example 20
Project: Technical   File: TechnicalWorldGenMinable.java   View Source Code Vote up 4 votes
public boolean generate(World world, Random random, int x, int y, int z) {
	float f = random.nextFloat() * (float) Math.PI;
	double d0 = (double) ((float) (x + 8) + MathHelper.sin(f) * (float) this.numberOfBlocks / 8.0F);
	double d1 = (double) ((float) (x + 8) - MathHelper.sin(f) * (float) this.numberOfBlocks / 8.0F);
	double d2 = (double) ((float) (z + 8) + MathHelper.cos(f) * (float) this.numberOfBlocks / 8.0F);
	double d3 = (double) ((float) (z + 8) - MathHelper.cos(f) * (float) this.numberOfBlocks / 8.0F);
	double d4 = (double) (y + random.nextInt(3) - 2);
	double d5 = (double) (y + random.nextInt(3) - 2);

	for(int l = 0; l <= this.numberOfBlocks; ++l) {
		double d6 = d0 + (d1 - d0) * (double) l / (double) this.numberOfBlocks;
		double d7 = d4 + (d5 - d4) * (double) l / (double) this.numberOfBlocks;
		double d8 = d2 + (d3 - d2) * (double) l / (double) this.numberOfBlocks;
		double d9 = random.nextDouble() * (double) this.numberOfBlocks / 16.0D;
		double d10 = (double) (MathHelper.sin((float) l * (float) Math.PI / (float) this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
		double d11 = (double) (MathHelper.sin((float) l * (float) Math.PI / (float) this.numberOfBlocks) + 1.0F) * d9 + 1.0D;
		int i1 = MathHelper.floor_double(d6 - d10 / 2.0D);
		int j1 = MathHelper.floor_double(d7 - d11 / 2.0D);
		int k1 = MathHelper.floor_double(d8 - d10 / 2.0D);
		int l1 = MathHelper.floor_double(d6 + d10 / 2.0D);
		int i2 = MathHelper.floor_double(d7 + d11 / 2.0D);
		int j2 = MathHelper.floor_double(d8 + d10 / 2.0D);

		for(int k2 = i1; k2 <= l1; ++k2) {
			double d12 = ((double) k2 + 0.5D - d6) / (d10 / 2.0D);

			if(d12 * d12 < 1.0D) {
				for(int l2 = j1; l2 <= i2; ++l2) {
					double d13 = ((double) l2 + 0.5D - d7) / (d11 / 2.0D);

					if(d12 * d12 + d13 * d13 < 1.0D) {
						for(int i3 = k1; i3 <= j2; ++i3) {
							double d14 = ((double) i3 + 0.5D - d8) / (d10 / 2.0D);

							if(d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && world.getBlock(k2, l2, i3).isReplaceableOreGen(world, k2, l2, i3, targetBlock)) {
								world.setBlock(k2, l2, i3, this.blocktoGen, mineableBlockMeta, 2);
							}
						}
					}
				}
			}
		}
	}
	return true;
}