Java Code Examples for net.minecraft.init.Blocks#end_stone()

The following examples show how to use net.minecraft.init.Blocks#end_stone() . 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: ChorusFlower.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
public static boolean canPlantStay(World world, int x, int y, int z) {
	Block block = world.getBlock(x, y - 1, z);
	if (block != ModBlocks.chorus_plant && block != Blocks.end_stone) {
		if (block.isAir(world, x, y - 1, z)) {
			int adjecentCount = 0;
			for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
				Block adjecentBlock = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
				if (adjecentBlock == ModBlocks.chorus_plant)
					adjecentCount++;
				else if (!adjecentBlock.isAir(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ))
					return false;
			}
			return adjecentCount == 1;
		} else
			return false;
	} else
		return true;
}
 
Example 2
Source File: EventHandlerPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onFertilization(BonemealEvent event){
    if(event.world.isRemote) return; // why would we want to handle this on the client-side?

    if(event.block == Blocks.netherrack || event.block == Blocks.end_stone || event.block.canSustainPlant(event.world, event.x, event.y, event.z, ForgeDirection.UP, Blocks.red_flower)) { // can bonemeal Biomes O' Plenty grass, etc.    			    			
        boolean onGrass = event.block instanceof BlockGrass;
        if(onGrass && Config.includePlantsOnBonemeal || !onGrass && Config.allowDirtBonemealing) {
            // we'll try to spawn plants in a 5x5 area which is centered on the block that has been bonemealed
            for(int x = event.x - 2; x < event.x + 3; x++) {
                for(int z = event.z - 2; z < event.z + 3; z++) {
                    if(event.world.isAirBlock(x, event.y + 1, z)) {
                        if(event.world.rand.nextInt(8) == 1) { // increase .nextInt(x) to lower the chances of spawning a plant
                            BlockPneumaticPlantBase trySpawn = BlockPlants.allPlants.get(event.world.rand.nextInt(BlockPlants.allPlants.size() - 1)); // select a random plant    							
                            if(trySpawn.canPlantGrowOnThisBlock(event.world.getBlock(x, event.y, z), event.world, x, event.y, z)) { // make sure that the plant we selected can grow on the soil
                                event.world.setBlock(x, event.y + (trySpawn.isPlantHanging() ? -1 : 1), z, trySpawn);
                            }
                        }
                    }
                }

                /*
                 * vanilla mechanics will spawn flowers etc. when bonemeal is used on grass,
                 * so we cannot set Result.ALLOW in this case because it would stop event-propagation
                 */
                if(!onGrass) event.setResult(Result.ALLOW);
            }
        }
    }
}
 
Example 3
Source File: ChorusFlower.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
	if (world.isRemote)
		return;
	int meta = world.getBlockMetadata(x, y, z);
	if (meta >= 5)
		return;

	if (!canBlockStay(world, x, y, z))
		world.func_147480_a(x, y, z, true);
	else if (world.isAirBlock(x, y + 1, z)) {
		boolean canGrowUp = false;
		boolean isSegmentOnEndstone = false;
		Block lowerBlock = world.getBlock(x, y - 1, z);
		if (lowerBlock == Blocks.end_stone)
			canGrowUp = true;
		else if (lowerBlock == ModBlocks.chorus_plant) {
			int par8 = 1;
			int height;
			for (height = 0; height < 4; height++) {
				Block b = world.getBlock(x, y - (par8 + 1), z);
				if (b != ModBlocks.chorus_plant) {
					if (b == Blocks.end_stone)
						isSegmentOnEndstone = true;
					break;
				}
				par8++;
			}

			height = 4;
			if (isSegmentOnEndstone)
				height++;

			if (par8 < 2 || rand.nextInt(height) >= par8)
				canGrowUp = true;
		} else if (lowerBlock.isAir(world, x, y - 1, z))
			canGrowUp = true;

		if (canGrowUp && isSpaceAroundFree(world, x, y + 1, z, ForgeDirection.DOWN) && world.isAirBlock(x, y + 2, z)) {
			world.setBlock(x, y, z, ModBlocks.chorus_plant);
			world.setBlock(x, y + 1, z, this, meta, 3);
		} else if (meta < 4) {
			int tries = rand.nextInt(4);
			boolean grew = false;
			if (isSegmentOnEndstone)
				tries++;
			for (int i = 0; i < tries; i++) {
				ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[rand.nextInt(ForgeDirection.VALID_DIRECTIONS.length)];
				int xx = x + dir.offsetX;
				int yy = y + dir.offsetY;
				int zz = z + dir.offsetZ;
				if (world.isAirBlock(xx, yy, zz) && isSpaceAroundFree(world, xx, yy, zz, dir.getOpposite())) {
					world.setBlock(xx, yy, zz, this, meta + 1, 3);
					grew = true;
				}
			}
			if (grew)
				world.setBlock(x, y, z, ModBlocks.chorus_plant, 0, 3);
			else
				world.setBlock(x, y, z, this, 5, 3);
		} else if (meta == 4)
			world.setBlock(x, y, z, this, 5, 3);
	}
}
 
Example 4
Source File: BlockChorusPlantRender.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	renderer.renderAllFaces = true;

	long seed = x * 3129871L ^ y * 116129781L ^ z;
	seed = seed * seed * 42317861L + seed * 11L;
	rand.setSeed(seed);

	int noConUp = rand.nextInt(5);
	int noConDown = rand.nextInt(5);
	int noConWest = rand.nextInt(5);
	int noConEast = rand.nextInt(5);
	int noConNorth = rand.nextInt(5);
	int noConSouth = rand.nextInt(5);

	Block neighbourUp = world.getBlock(x + ForgeDirection.UP.offsetX, y + ForgeDirection.UP.offsetY, z + ForgeDirection.UP.offsetZ);
	Block neighbourDown = world.getBlock(x + ForgeDirection.DOWN.offsetX, y + ForgeDirection.DOWN.offsetY, z + ForgeDirection.DOWN.offsetZ);
	Block neighbourWest = world.getBlock(x + ForgeDirection.WEST.offsetX, y + ForgeDirection.WEST.offsetY, z + ForgeDirection.WEST.offsetZ);
	Block neighbourEast = world.getBlock(x + ForgeDirection.EAST.offsetX, y + ForgeDirection.EAST.offsetY, z + ForgeDirection.EAST.offsetZ);
	Block neighbourNorth = world.getBlock(x + ForgeDirection.NORTH.offsetX, y + ForgeDirection.NORTH.offsetY, z + ForgeDirection.NORTH.offsetZ);
	Block neighbourSouth = world.getBlock(x + ForgeDirection.SOUTH.offsetX, y + ForgeDirection.SOUTH.offsetY, z + ForgeDirection.SOUTH.offsetZ);
	float conWidth = 4 / 16F;

	if (neighbourUp == ModBlocks.chorus_flower || neighbourUp == Blocks.end_stone || neighbourUp == block) {
		renderer.setRenderBounds(conWidth, 1 - conWidth, conWidth, 1 - conWidth, 1, 1 - conWidth);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConUp == 2 || noConUp == 3) {
		renderer.setRenderBounds(conWidth, 1 - conWidth, conWidth, 1 - conWidth, 13 / 16F, 1 - conWidth);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConUp == 4) {
		renderer.setRenderBounds(5 / 16F, 1 - conWidth, 5 / 16F, 11 / 16F, 1 - 2 / 16F, 11 / 16F);
		renderer.renderStandardBlock(block, x, y, z);
	}

	if (neighbourDown == ModBlocks.chorus_flower || neighbourDown == Blocks.end_stone || neighbourDown == block) {
		renderer.setRenderBounds(conWidth, 0, conWidth, 1 - conWidth, conWidth, 1 - conWidth);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConDown == 2 || noConDown == 3) {
		renderer.setRenderBounds(conWidth, 3 / 16F, conWidth, 1 - conWidth, conWidth, 1 - conWidth);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConDown == 4) {
		renderer.setRenderBounds(5 / 16F, 2 / 16F, 5 / 16F, 11 / 16F, conWidth, 11 / 16F);
		renderer.renderStandardBlock(block, x, y, z);
	}

	if (neighbourWest == ModBlocks.chorus_flower || neighbourWest == Blocks.end_stone || neighbourWest == block) {
		renderer.setRenderBounds(0, conWidth, conWidth, conWidth, 1 - conWidth, 1 - conWidth);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConWest == 2 || noConWest == 3) {
		renderer.setRenderBounds(3 / 16F, conWidth, conWidth, conWidth, 1 - conWidth, 1 - conWidth);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConWest == 4) {
		renderer.setRenderBounds(2 / 16F, 5 / 16F, 5 / 16F, conWidth, 11 / 16F, 11 / 16F);
		renderer.renderStandardBlock(block, x, y, z);
	}

	if (neighbourEast == ModBlocks.chorus_flower || neighbourEast == Blocks.end_stone || neighbourEast == block) {
		renderer.setRenderBounds(1 - conWidth, conWidth, conWidth, 1, 1 - conWidth, 1 - conWidth);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConEast == 2 || noConEast == 3) {
		renderer.setRenderBounds(1 - conWidth, conWidth, conWidth, 13 / 16F, 1 - conWidth, 1 - conWidth);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConEast == 4) {
		renderer.setRenderBounds(1 - conWidth, 5 / 16F, 5 / 16F, 1 - 2 / 16F, 11 / 16F, 11 / 16F);
		renderer.renderStandardBlock(block, x, y, z);
	}

	if (neighbourNorth == ModBlocks.chorus_flower || neighbourNorth == Blocks.end_stone || neighbourNorth == block) {
		renderer.setRenderBounds(conWidth, conWidth, 0, 1 - conWidth, 1 - conWidth, conWidth);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConNorth == 2 || noConNorth == 3) {
		renderer.setRenderBounds(conWidth, conWidth, 3 / 16F, 1 - conWidth, 1 - conWidth, conWidth);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConNorth == 4) {
		renderer.setRenderBounds(5 / 16F, 5 / 16F, 2 / 16F, 11 / 16F, 11 / 16F, conWidth);
		renderer.renderStandardBlock(block, x, y, z);
	}

	if (neighbourSouth == ModBlocks.chorus_flower || neighbourSouth == Blocks.end_stone || neighbourSouth == block) {
		renderer.setRenderBounds(conWidth, conWidth, 1 - conWidth, 1 - conWidth, 1 - conWidth, 1);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConSouth == 2 || noConSouth == 3) {
		renderer.setRenderBounds(conWidth, conWidth, 1 - conWidth, 1 - conWidth, 1 - conWidth, 13 / 16F);
		renderer.renderStandardBlock(block, x, y, z);
	} else if (noConSouth == 4) {
		renderer.setRenderBounds(5 / 16F, 5 / 16F, 1 - conWidth, 11 / 16F, 11 / 16F, 1 - 2 / 16F);
		renderer.renderStandardBlock(block, x, y, z);
	}

	renderer.setRenderBounds(conWidth, conWidth, conWidth, 1 - conWidth, 1 - conWidth, 1 - conWidth);
	renderer.renderStandardBlock(block, x, y, z);

	return true;
}
 
Example 5
Source File: ArchimedesConfig.java    From archimedes-ships with MIT License 4 votes vote down vote up
public void loadAndSave()
{
	Block[] defaultBlockBlacklist = { (Blocks.dirt), (Blocks.grass), (Blocks.sand), (Blocks.gravel), (Blocks.clay), (Blocks.ice), (Blocks.water), (Blocks.flowing_water), (Blocks.flowing_lava), (Blocks.lava), (Blocks.snow), Blocks.snow_layer, (Blocks.waterlily), (Blocks.netherrack), (Blocks.soul_sand), Blocks.tallgrass };
	Block[] defaultBlocksWhitelist = { Blocks.acacia_stairs, Blocks.activator_rail, Blocks.anvil, Blocks.bed, Blocks.birch_stairs, Blocks.bookshelf, Blocks.brewing_stand, Blocks.brick_block, Blocks.brick_stairs, Blocks.cactus, Blocks.cake, Blocks.carpet, Blocks.coal_block, Blocks.cobblestone, Blocks.cobblestone_wall, Blocks.command_block, Blocks.crafting_table, Blocks.dark_oak_stairs, Blocks.detector_rail, Blocks.diamond_block, Blocks.dispenser, Blocks.dropper, Blocks.daylight_detector, Blocks.double_stone_slab, Blocks.double_wooden_slab, Blocks.emerald_block, Blocks.enchanting_table, Blocks.end_stone, Blocks.ender_chest, Blocks.fence, Blocks.fence_gate, Blocks.flower_pot, Blocks.furnace, Blocks.fire, Blocks.glass, Blocks.glass_pane, Blocks.glowstone, Blocks.gold_block, Blocks.golden_rail, Blocks.hardened_clay, Blocks.hay_block, Blocks.heavy_weighted_pressure_plate, Blocks.hopper, Blocks.iron_bars, Blocks.iron_block, Blocks.iron_door, Blocks.jukebox, Blocks.jungle_stairs, Blocks.ladder, Blocks.lapis_block, Blocks.lever, Blocks.light_weighted_pressure_plate, Blocks.lit_furnace, Blocks.lit_pumpkin, Blocks.lit_redstone_lamp, Blocks.log, Blocks.log2, Blocks.melon_block, Blocks.mob_spawner, Blocks.monster_egg, Blocks.mossy_cobblestone, Blocks.nether_brick, Blocks.nether_brick_fence, Blocks.nether_brick_stairs, Blocks.noteblock, Blocks.oak_stairs, Blocks.obsidian, Blocks.planks, Blocks.pumpkin, Blocks.piston, Blocks.piston_extension, Blocks.piston_head, Blocks.powered_comparator, Blocks.powered_repeater, Blocks.quartz_block, Blocks.quartz_stairs, Blocks.rail, Blocks.redstone_block, Blocks.redstone_torch, Blocks.redstone_wire, Blocks.sandstone, Blocks.sandstone_stairs, Blocks.skull, Blocks.sponge, Blocks.spruce_stairs, Blocks.stained_hardened_clay, Blocks.standing_sign, Blocks.stone_brick_stairs, Blocks.stone_button, Blocks.stone_pressure_plate, Blocks.stone_stairs, Blocks.stonebrick, Blocks.stained_glass, Blocks.stained_glass_pane, Blocks.sticky_piston, Blocks.stone_slab, Blocks.tnt, Blocks.torch, Blocks.trapdoor, Blocks.trapped_chest, Blocks.tripwire, Blocks.tripwire_hook, Blocks.unlit_redstone_torch, Blocks.unpowered_comparator, Blocks.unpowered_repeater, Blocks.wall_sign, Blocks.web, Blocks.wooden_button, Blocks.wooden_door, Blocks.wooden_pressure_plate, Blocks.wool, Blocks.wooden_slab };
	Block[] defaultOverwritableBlocks = { Blocks.tallgrass, Blocks.waterlily };
	String[] defaultMaterialDensities = { "\"minecraft:air=0.0\"", "\"minecraft:wool=0.1\"" };
	String[] defaultBlockDensities = { "\"ArchimedesShips:floater=0.04\"", "\"ArchimedesShips:balloon=0.02\"" };
	
	String[] blockblacklistnames = new String[defaultBlockBlacklist.length];
	for (int i = 0; i < defaultBlockBlacklist.length; i++)
	{
		blockblacklistnames[i] = Block.blockRegistry.getNameForObject(defaultBlockBlacklist[i]);
	}
	
	String[] blockwhitelistnames = new String[6 + defaultBlocksWhitelist.length];
	for (int i = 0; i < blockwhitelistnames.length - 6; i++)
	{
		blockwhitelistnames[i] = Block.blockRegistry.getNameForObject(defaultBlocksWhitelist[i]);
	}
	blockwhitelistnames[blockwhitelistnames.length - 6] = "ArchimedesShips:marker";
	blockwhitelistnames[blockwhitelistnames.length - 5] = "ArchimedesShips:floater";
	blockwhitelistnames[blockwhitelistnames.length - 4] = "ArchimedesShips:balloon";
	blockwhitelistnames[blockwhitelistnames.length - 3] = "ArchimedesShips:gauge";
	blockwhitelistnames[blockwhitelistnames.length - 2] = "ArchimedesShips:seat";
	blockwhitelistnames[blockwhitelistnames.length - 1] = "ArchimedesShips:engine";
	
	String[] overwritableblocksnames = new String[defaultOverwritableBlocks.length];
	for (int i = 0; i < defaultOverwritableBlocks.length; i++)
	{
		overwritableblocksnames[i] = Block.blockRegistry.getNameForObject(defaultOverwritableBlocks[i]);
	}
	
	config.load();
	
	shipEntitySyncRate = config.get("settings", "sync_rate", 20, "The amount of ticks between a server-client synchronization. Higher numbers reduce network traffic. Lower numbers increase multiplayer experience. 20 ticks = 1 second").getInt();
	enableAirShips = config.get("settings", "enable_air_ships", true, "Enable or disable air ships.").getBoolean(true);
	useNewAlgorithm = config.get("settings", "use_iterative_assemble_algorithm", false, "New assemble algorithm implemented in v1.6.2. Allows for larger ships but is a heavier load for CPU.").getBoolean(false);
	bankingMultiplier = (float) config.get("settings", "banking_multiplier", 3d, "A multiplier for how much ships bank while making turns. Set a positive value for passive banking or a negative value for active banking. 0 disables banking.").getDouble(3d);
	
	shipControlType = config.get("control", "control_type", CONTROL_TYPE_ARCHIMEDES, "Set to 0 to use vanilla boat controls, set to 1 to use the new Archimedes controls.").getInt();
	turnSpeed = (float) config.get("control", "turn_speed", 1D, "A multiplier of the ship's turn speed.").getDouble(1D);
	speedLimit = (float) config.get("control", "speed_limit", 30D, "The maximum velocity a ship can have, in blocks per second. This does not affect acceleration.").getDouble(30D);
	speedLimit /= 20F;
	disassembleOnDismount = config.get("control", "decompile_on_dismount", false).getBoolean(false);
	
	maxShipChunkBlocks = config.get("mobile_chunk", "max_chunk_blocks", 2048, "The maximum amount of blocks that a mobile ship chunk may contain.").getInt();
	//maxShipChunkBlocks = Math.min(maxShipChunkBlocks, 3400);
	flyBalloonRatio = (float) config.get("mobile_chunk", "airship_balloon_ratio", 0.4D, "The part of the total amount of blocks that should be balloon blocks in order to make an airship.").getDouble(0.4D);
	connectDiagonalBlocks1 = config.get("mobile_chunk", "connect_diagonal_blocks_1", false, "Blocks connected diagonally on one axis will also be added to the ship if this value is set to 'true'.").getBoolean(false);
	useWhitelist = config.get("mobile_chunk", "use_whitelist", false, "Switch this property to select the block restriction list to use. 'true' for the 'allowed_blocks' whitelist, 'false' for the 'forbidden_blocks' blacklist.").getBoolean(false);
	String[] forbiddenblocks = config.get("mobile_chunk", "forbidden_blocks", blockblacklistnames, "A list of blocks that will not be added to a ship.").getStringList();
	String[] allowedblocks = config.get("mobile_chunk", "allowed_blocks", blockwhitelistnames, "A list of blocks that are allowed on a ship.").getStringList();
	String[] overwritableblocks = config.get("mobile_chunk", "overwritable_blocks", overwritableblocksnames, "A list of blocks that may be overwritten when decompiling a ship.").getStringList();
	Collections.addAll(blockBlacklist, forbiddenblocks);
	Collections.addAll(blockWhitelist, allowedblocks);
	Collections.addAll(overwritableBlocks, overwritableblocks);
	
	loadedBlockDensities = config.get("mobile_chunk", "block_densities", defaultBlockDensities, "A list of pairs of a block with a density value. This list overrides the 'material_densities' list.").getStringList();
	loadedMaterialDensities = config.get("mobile_chunk", "material_densities", defaultMaterialDensities, "A list of pairs of a material with a density value. The first value is the name of a block. All blocks with the same material will get this density value, unless overridden.").getStringList();
	
	if (FMLCommonHandler.instance().getSide().isClient())
	{
		loadKeybindings();
	}
	
	config.save();
}
 
Example 6
Source File: Forestry.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected ItemStack getEarth(){
    return new ItemStack(Blocks.end_stone);
}
 
Example 7
Source File: BlockEnderPlant.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canPlantGrowOnThisBlock(Block blockID, World world, int x, int y, int z){
    return blockID == Blocks.end_stone;
}