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

The following are Jave code examples for showing how to use getHeight() 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.
Example 1
Project: harshencastle   File: PontusBiomeDecorator.java   Source Code and License Vote up 6 votes
@Override
protected void genDecorations(Biome biomeIn, World worldIn, Random random) {
	 			 	
	 	int k1 = this.treesPerChunk;
        if (random.nextFloat() < this.extraTreeChance)
        {
            ++k1;
        }

        if(net.minecraftforge.event.terraingen.TerrainGen.decorate(worldIn, random, chunkPos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.TREE))
        for (int j2 = 0; j2 < k1; ++j2)
        {
            int k6 = random.nextInt(16) + 8;
            int l = random.nextInt(16) + 8;
            WorldGenAbstractTree worldgenabstracttree = biomeIn.getRandomTreeFeature(random);
            worldgenabstracttree.setDecorationDefaults();
            BlockPos blockpos = worldIn.getHeight(this.chunkPos.add(k6, 0, l));

            if (worldgenabstracttree.generate(worldIn, random, blockpos))
            {
                worldgenabstracttree.generateSaplings(worldIn, random, blockpos);
            }
        }
}
 
Example 2
Project: ExPetrum   File: ExPBiomeDecorator.java   Source Code and License Vote up 6 votes
public void seaweedPassGenerate(World worldIn, Random rand, Biome biome, BlockPos pos)
{
	if (!(biome instanceof IBiome) || !((IBiome)biome).isWaterSalt())
	{
		return;
	}
	
	int x = rand.nextInt(16) + 8;
	int z = rand.nextInt(16) + 8;
	BlockPos at = worldIn.getHeight(pos.add(x, 0, z));
	EventGenVegetation event = new EventGenVegetation(worldIn, at, rand, genSeaweed, Type.SEAWEED);
	if (MinecraftForge.TERRAIN_GEN_BUS.post(event))
	{
		return;
	}
	
	event.generator.generate(worldIn, rand, at);
}
 
Example 3
Project: ExPetrum   File: ExPBiomeDecorator.java   Source Code and License Vote up 6 votes
public void cropsPassGenerate(World worldIn, Random rand, Biome biome, BlockPos pos)
{
	if (!(biome instanceof ExPBiome))
	{
		return;
	}
	
	int x = rand.nextInt(16) + 8;
	int z = rand.nextInt(16) + 8;
	BlockPos at = worldIn.getHeight(pos.add(x, 0, z));
	
	WorldGenerator cropsGen = new CropGenerator((ExPBiome) biome);
	EventGenVegetation event = new EventGenVegetation(worldIn, at, rand, cropsGen, Type.WILD_CROP);
	if (MinecraftForge.TERRAIN_GEN_BUS.post(event))
	{
		return;
	}
	
	event.generator.generate(worldIn, rand, at);
}
 
Example 4
Project: World-Border   File: DynMapFeatures.java   Source Code and License Vote up 5 votes
public static void renderRegion(World world, CoordXZ coord)
{
    if (!enabled) return;

    int y = (world != null) ? world.getHeight() : 255;
    int x = CoordXZ.regionToBlock(coord.x);
    int z = CoordXZ.regionToBlock(coord.z);
    Gateway.api.triggerRenderOfVolume(Worlds.getWorldName(world), x, 0, z, x + 511, y, z + 511);
}
 
Example 5
Project: modName   File: BiomeTundra.java   Source Code and License Vote up 5 votes
@Override
public void decorate(World worldIn, Random rand, BlockPos pos) {
    int boulders = rand.nextInt(3)-1;

    for (int i = 0; i < boulders; i++) {
        int x = rand.nextInt(16) + 8;
        int z = rand.nextInt(16) + 8;
        BlockPos blockpos = worldIn.getHeight(pos.add(x, 0, z));
        ATGBiomes.Features.BOULDER_COBBLE.generate(worldIn, rand, blockpos);
    }

    super.decorate(worldIn, rand, pos);
}
 
Example 6
Project: Backmemed   File: DebugRendererHeightMap.java   Source Code and License Vote up 5 votes
public void render(float p_190060_1_, long p_190060_2_)
{
    EntityPlayer entityplayer = this.minecraft.player;
    World world = this.minecraft.world;
    double d0 = entityplayer.lastTickPosX + (entityplayer.posX - entityplayer.lastTickPosX) * (double)p_190060_1_;
    double d1 = entityplayer.lastTickPosY + (entityplayer.posY - entityplayer.lastTickPosY) * (double)p_190060_1_;
    double d2 = entityplayer.lastTickPosZ + (entityplayer.posZ - entityplayer.lastTickPosZ) * (double)p_190060_1_;
    GlStateManager.pushMatrix();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    GlStateManager.disableTexture2D();
    BlockPos blockpos = new BlockPos(entityplayer.posX, 0.0D, entityplayer.posZ);
    Iterable<BlockPos> iterable = BlockPos.getAllInBox(blockpos.add(-40, 0, -40), blockpos.add(40, 0, 40));
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    vertexbuffer.begin(5, DefaultVertexFormats.POSITION_COLOR);

    for (BlockPos blockpos1 : iterable)
    {
        int i = world.getHeight(blockpos1.getX(), blockpos1.getZ());

        if (world.getBlockState(blockpos1.add(0, i, 0).down()) == Blocks.AIR.getDefaultState())
        {
            RenderGlobal.addChainedFilledBoxVertices(vertexbuffer, (double)((float)blockpos1.getX() + 0.25F) - d0, (double)i - d1, (double)((float)blockpos1.getZ() + 0.25F) - d2, (double)((float)blockpos1.getX() + 0.75F) - d0, (double)i + 0.09375D - d1, (double)((float)blockpos1.getZ() + 0.75F) - d2, 0.0F, 0.0F, 1.0F, 0.5F);
        }
        else
        {
            RenderGlobal.addChainedFilledBoxVertices(vertexbuffer, (double)((float)blockpos1.getX() + 0.25F) - d0, (double)i - d1, (double)((float)blockpos1.getZ() + 0.25F) - d2, (double)((float)blockpos1.getX() + 0.75F) - d0, (double)i + 0.09375D - d1, (double)((float)blockpos1.getZ() + 0.75F) - d2, 0.0F, 1.0F, 0.0F, 0.5F);
        }
    }

    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();
}
 
Example 7
Project: Got-Wood   File: WorldGenMaple.java   Source Code and License Vote up 5 votes
private boolean isAreaClear(World worldIn, BlockPos position, int treeheight) {
	boolean flag = false;
	for (int j = position.getY(); j <= position.getY() + 1 + treeheight; ++j) {
		int k = 1;

		if (j == position.getY()) {
			k = 0;
		}

		if (j >= position.getY() + 1 + treeheight - 2) {
			k = 1;
		}

		BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos();

		for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
			for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
				if (j >= 0 && j < worldIn.getHeight()) {
					if (!this.isReplaceable(worldIn, blockposmutableblockpos.setPos(l, j, i1))) {
						return false;
					}
				} else {
					return false;
				}
			}
		}
	}
	return true;
}
 
Example 8
Project: CustomWorldGen   File: BiomeTaiga.java   Source Code and License Vote up 5 votes
public void decorate(World worldIn, Random rand, BlockPos pos)
{
    if ((this.type == BiomeTaiga.Type.MEGA || this.type == BiomeTaiga.Type.MEGA_SPRUCE) && net.minecraftforge.event.terraingen.TerrainGen.decorate(worldIn, rand, pos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.ROCK))
    {
        int i = rand.nextInt(3);

        for (int j = 0; j < i; ++j)
        {
            int k = rand.nextInt(16) + 8;
            int l = rand.nextInt(16) + 8;
            BlockPos blockpos = worldIn.getHeight(pos.add(k, 0, l));
            FOREST_ROCK_GENERATOR.generate(worldIn, rand, blockpos);
        }
    }

    DOUBLE_PLANT_GENERATOR.setPlantType(BlockDoublePlant.EnumPlantType.FERN);

    if(net.minecraftforge.event.terraingen.TerrainGen.decorate(worldIn, rand, pos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.FLOWERS))
    for (int i1 = 0; i1 < 7; ++i1)
    {
        int j1 = rand.nextInt(16) + 8;
        int k1 = rand.nextInt(16) + 8;
        int l1 = rand.nextInt(worldIn.getHeight(pos.add(j1, 0, k1)).getY() + 32);
        DOUBLE_PLANT_GENERATOR.generate(worldIn, rand, pos.add(j1, l1, k1));
    }

    super.decorate(worldIn, rand, pos);
}
 
Example 9
Project: Got-Wood   File: WorldGenPalm.java   Source Code and License Vote up 5 votes
private boolean isAreaClear(World worldIn, BlockPos position, int treeheight) {
	boolean flag = false;
	for (int j = position.getY(); j <= position.getY() + 1 + treeheight; ++j) {
		int k = 1;

		if (j == position.getY()) {
			k = 0;
		}

		if (j >= position.getY() + 1 + treeheight - 2) {
			k = 1;
		}

		BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos();

		for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
			for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
				if (j >= 0 && j < worldIn.getHeight()) {
					if (!this.isReplaceable(worldIn, blockposmutableblockpos.setPos(l, j, i1))) {
						return false;
					}
				} else {
					return false;
				}
			}
		}
	}
	return true;
}
 
Example 10
Project: PurificatiMagicae   File: WGLabSmall.java   Source Code and License Vote up 5 votes
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
{
    if (dimList.contains(world.provider.getDimension()) == dimListMode)
    {
        if (random.nextFloat() <= chance)
        {
            int x = chunkX * 16 + 16;
            int z = chunkZ * 16 + 16;
            BlockPos pos = new BlockPos(x, world.getHeight(x, z) - 7, z);
            if (pos.getY() >= minY && pos.getY() <= maxY)
            {
                try
                {
                    NBTTagCompound tag = StructureApi.INSTANCE.getStructureNbt(Utils.gRL("lab_small"));
                    PurMag.INSTANCE.debug("WG START [lab_small]");
                    StructureApi.INSTANCE.spawnStructure(tag, pos, null, Rotation.values()[random.nextInt(Rotation.values().length)], (WorldServer) world, random);
                    PurMag.INSTANCE.debug("WG END AT " + pos);
                }
                catch (IOException e)
                {
                    PurMag.INSTANCE.log.error("An IOException occurred when spawning the small lab structure!", e);
                }
            }
        }
    }
}
 
Example 11
Project: TechReborn3   File: RubberPlantationDecorator.java   Source Code and License Vote up 5 votes
@Override
protected void genDecorations(Biome biomeIn, World worldIn, Random random) {
	for (int chance = 0; chance < rubberTreesPerChunk; ++chance) {
		BlockPos blockpos = worldIn.getHeight(this.chunkPos);
		treeGenerator.generate(worldIn, random, blockpos);
	}
	super.genDecorations(biomeIn, worldIn, random);
}
 
Example 12
Project: PurificatiMagicae   File: WGLabMedium.java   Source Code and License Vote up 5 votes
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
{
    if (dimList.contains(world.provider.getDimension()) == dimListMode)
    {
        if (random.nextFloat() <= chance)
        {
            int x = chunkX * 16 + 16;
            int z = chunkZ * 16 + 16;
            BlockPos pos = new BlockPos(x, world.getHeight(x, z) - 1, z);
            if (pos.getY() >= minY && pos.getY() <= maxY)
            {
                try
                {
                    NBTTagCompound tag = StructureApi.INSTANCE.getStructureNbt(Utils.gRL("lab_medium"));
                    PurMag.INSTANCE.debug("WG START [lab_medium]");
                    StructureApi.INSTANCE.spawnStructure(tag, pos, null, Rotation.values()[random.nextInt(Rotation.values().length)], (WorldServer) world, random);
                    PurMag.INSTANCE.debug("WG END AT " + pos);
                }
                catch (IOException e)
                {
                    PurMag.INSTANCE.log.error("An IOException occurred when spawning the small lab structure!", e);
                }
            }
        }
    }
}
 
Example 13
Project: Got-Wood   File: WorldGenRubber.java   Source Code and License Vote up 4 votes
public boolean generate(World worldIn, Random rand, BlockPos position) {
	int i = 2 + rand.nextInt(1) + this.minTreeHeight;
	boolean flag = true;

	if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
		for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
			int k = 1;

			if (j == position.getY()) {
				k = 0;
			}

			if (j >= position.getY() + 1 + i - 2) {
				k = 2;
			}

			BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos();

			for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
				for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
					if (j >= 0 && j < worldIn.getHeight()) {
						if (!this.isReplaceable(worldIn, blockposmutableblockpos.setPos(l, j, i1))) {
							flag = false;
						}
					} else {
						flag = false;
					}
				}
			}
		}

		if (!flag) {
			return false;
		} else {
			IBlockState state = worldIn.getBlockState(position.down());

			if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
				this.setDirtAt(worldIn, position.down());

				for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) {
					int i4 = i3 - (position.getY() + i);
					int j1 = 1 - i4 / 2;

					for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) {
						int l1 = k1 - position.getX();

						for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) {
							int j2 = i2 - position.getZ();

							if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) {
								BlockPos blockpos = new BlockPos(k1, i3, i2);
								state = worldIn.getBlockState(blockpos);

								if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) {
									this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves);
								}
							}
						}
					}
				}

				for (int j3 = 0; j3 < i; ++j3) {
					BlockPos upN = position.up(j3);
					state = worldIn.getBlockState(upN);

					if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) {
						this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood);
					}
				}

				return true;
			} else {
				return false;
			}
		}
	} else {
		return false;
	}
}
 
Example 14
Project: Got-Wood   File: WorldGenMaple.java   Source Code and License Vote up 4 votes
private boolean generateNormal(World worldIn, Random rand, BlockPos position) {
	int i = rand.nextInt(3) + 5;
	boolean flag = true;

	if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {

		flag = isAreaClear(worldIn, position, i);

		if (!flag) {
			return false;
		} else {
			IBlockState state = worldIn.getBlockState(position.down());

			if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
				this.setDirtAt(worldIn, position.down());

				for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) {
					int i4 = i3 - (position.getY() + i);
					int j1 = 1 - i4 / 2;

					for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) {
						int l1 = k1 - position.getX();

						for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) {
							int j2 = i2 - position.getZ();

							if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) {
								BlockPos blockpos = new BlockPos(k1, i3, i2);
								state = worldIn.getBlockState(blockpos);

								if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) {
									this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves);
								}
							}
						}
					}
				}

				for (int j3 = 0; j3 < i; ++j3) {
					BlockPos upN = position.up(j3);
					state = worldIn.getBlockState(upN);

					if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) {
						this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood);
					}
				}

				return true;
			} else {
				return false;
			}
		}
	} else {
		return false;
	}
}
 
Example 15
Project: Got-Wood   File: WorldGenMaple.java   Source Code and License Vote up 4 votes
private boolean generateBig(World worldIn, Random rand, BlockPos position) {
	int i = rand.nextInt(2) + 9;
	boolean flag = true;

	if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
		flag = isAreaClear(worldIn, position, i);

		if (!flag) {
			return false;
		}

		//If we can actually make the tree
		else {
			IBlockState state = worldIn.getBlockState(position.down());

			if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
				this.setDirtAt(worldIn, position.down());

				//MAKE LEAVES
				final int[][] leafPos = new int[][] { { -1, 0, 0 }, { 0, 0, 1 }, { 0, 0, -1 }, { 1, 0, 0 }, { -1, 1, 1 }, { -1, 1, 0 }, { -1, 1, -1 }, { 0, 1, 1 }, { 0, 1, -1 }, { 1, 1, 1 }, { 1, 1, 0 }, { 1, 1, -1 }, { 2, 1, 1 }, { -2, 1, 1 }, { -2, 1, 0 }, { -2, 1, -1 }, { -1, 1, 2 }, { -1, 1, -2 }, { 0, 1, 2 }, { 0, 1, -2 }, { 2, 1, 0 }, { 2, 1, -1 }, { 1, 1, 2 }, { 1, 1, -2 }, { -3, 1, 0 }, { 3, 1, 0 }, { 0, 1, -3 }, { 0, 1, 3 }, { -2, 1, 2 }, { -2, 1, -2 }, { 2, 1, 2 }, { 2, 1, -2 }, { -1, 2, 1 }, { -1, 2, 0 }, { -1, 2, -1 }, { 0, 2, 1 }, { 0, 2, -1 }, { 1, 2, 1 }, { 1, 2, 0 }, { 1, 2, -1 }, { 2, 2, 1 }, { -2, 2, 1 }, { -2, 2, 0 }, { -2, 2, -1 }, { -1, 2, 2 }, { -1, 2, -2 }, { 0, 2, 2 }, { 0, 2, -2 }, { 2, 2, 0 }, { 2, 2, -1 }, { 1, 2, 2 }, { 1, 2, -2 }, { -3, 2, 0 }, { 3, 2, 0 },
					{ 0, 2, -3 }, { 0, 2, 3 }, { -2, 2, 2 }, { -2, 2, -2 }, { 2, 2, 2 }, { 2, 2, -2 }, { -3, 2, -1 }, { -3, 2, 1 }, { -1, 2, -3 }, { -1, 2, 3 }, { 1, 2, 3 }, { 3, 2, 1 }, { 1, 2, -3 }, { 3, 2, -1 }, { -1, 3, 1 }, { -1, 3, 0 }, { -1, 3, -1 }, { 0, 3, 1 }, { 0, 3, -1 }, { 1, 3, 1 }, { 1, 3, 0 }, { 1, 3, -1 }, { 2, 3, 1 }, { -2, 3, 1 }, { -2, 3, 0 }, { -2, 3, -1 }, { -1, 3, 2 }, { -1, 3, -2 }, { 0, 3, 2 }, { 0, 3, -2 }, { 2, 3, 0 }, { 2, 3, -1 }, { 1, 3, 2 }, { 1, 3, -2 }, { -3, 3, 0 }, { 3, 3, 0 }, { 0, 3, -3 }, { 0, 3, 3 }, { -2, 3, 2 }, { -2, 3, -2 }, { 2, 3, 2 }, { 2, 3, -2 }, { -3, 3, -1 }, { -3, 3, 1 }, { -1, 3, -3 }, { -1, 3, 3 }, { 1, 3, 3 }, { 3, 3, 1 }, { 1, 3, -3 }, { 3, 3, -1 }, { -1, 4, 1 }, { -1, 4, 0 }, { -1, 4, -1 }, { 0, 4, 1 }, { 0, 4, -1 }, { 1, 4, 1 },
					{ 1, 4, 0 }, { 1, 4, -1 }, { 2, 4, 1 }, { -2, 4, 1 }, { -2, 4, 0 }, { -2, 4, -1 }, { -1, 4, 2 }, { -1, 4, -2 }, { 0, 4, 2 }, { 0, 4, -2 }, { 2, 4, 0 }, { 2, 4, -1 }, { 1, 4, 2 }, { 1, 4, -2 }, { -3, 4, 0 }, { 3, 4, 0 }, { 0, 4, -3 }, { 0, 4, 3 }, { -1, 5, 1 }, { -1, 5, 0 }, { -1, 5, -1 }, { 0, 5, 1 }, { 0, 5, -1 }, { 1, 5, 1 }, { 1, 5, 0 }, { 1, 5, -1 }, { 2, 5, 1 }, { -2, 5, 1 }, { -2, 5, 0 }, { -2, 5, -1 }, { -1, 5, 2 }, { -1, 5, -2 }, { 0, 5, 2 }, { 0, 5, -2 }, { 2, 5, 0 }, { 2, 5, -1 }, { 1, 5, 2 }, { 1, 5, -2 }, { -1, 6, 0 }, { 0, 6, 1 }, { 0, 6, -1 }, { 1, 6, 0 }, { 0, 7, 0 } };

				for (int[] coord : leafPos) {
					BlockPos blockpos = position.add(coord[0], coord[1] + (i - 7), coord[2]);
					state = worldIn.getBlockState(blockpos);
					if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) {
						this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves);
					}
				}

				//MAKE TRUNK
				for (int j3 = 0; j3 < i; ++j3) {
					BlockPos upN = position.up(j3);
					state = worldIn.getBlockState(upN);

					if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) {
						this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood);
						if (j3 == i - 4) {

							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							if (rand.nextBoolean()) {
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
							}

						} else if (j3 == i - 6) {
							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							if (rand.nextBoolean()) {
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
							}
						}
					}
				}

				return true;
			} else {
				return false;
			}
		}
	} else {
		return false;
	}
}
 
Example 16
Project: Got-Wood   File: WorldGenPalm.java   Source Code and License Vote up 4 votes
private boolean generateBig(World worldIn, Random rand, BlockPos position) {
	int i = rand.nextInt(2) + 9;
	boolean flag = true;

	if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
		flag = isAreaClear(worldIn, position, i);

		if (!flag) {
			return false;
		}

		//If we can actually make the tree
		else {
			IBlockState state = worldIn.getBlockState(position.down());

			if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
				this.setDirtAt(worldIn, position.down());

				//MAKE LEAVES
				final int[][] leafPos = new int[][] { { -1, 0, 0 }, { 0, 0, 1 }, { 0, 0, -1 }, { 1, 0, 0 }, { -1, 1, 1 }, { -1, 1, 0 }, { -1, 1, -1 }, { 0, 1, 1 }, { 0, 1, -1 }, { 1, 1, 1 }, { 1, 1, 0 }, { 1, 1, -1 }, { 2, 1, 1 }, { -2, 1, 1 }, { -2, 1, 0 }, { -2, 1, -1 }, { -1, 1, 2 }, { -1, 1, -2 }, { 0, 1, 2 }, { 0, 1, -2 }, { 2, 1, 0 }, { 2, 1, -1 }, { 1, 1, 2 }, { 1, 1, -2 }, { -3, 1, 0 }, { 3, 1, 0 }, { 0, 1, -3 }, { 0, 1, 3 }, { -2, 1, 2 }, { -2, 1, -2 }, { 2, 1, 2 }, { 2, 1, -2 }, { -1, 2, 1 }, { -1, 2, 0 }, { -1, 2, -1 }, { 0, 2, 1 }, { 0, 2, -1 }, { 1, 2, 1 }, { 1, 2, 0 }, { 1, 2, -1 }, { 2, 2, 1 }, { -2, 2, 1 }, { -2, 2, 0 }, { -2, 2, -1 }, { -1, 2, 2 }, { -1, 2, -2 }, { 0, 2, 2 }, { 0, 2, -2 }, { 2, 2, 0 }, { 2, 2, -1 }, { 1, 2, 2 }, { 1, 2, -2 }, { -3, 2, 0 }, { 3, 2, 0 },
					{ 0, 2, -3 }, { 0, 2, 3 }, { -2, 2, 2 }, { -2, 2, -2 }, { 2, 2, 2 }, { 2, 2, -2 }, { -3, 2, -1 }, { -3, 2, 1 }, { -1, 2, -3 }, { -1, 2, 3 }, { 1, 2, 3 }, { 3, 2, 1 }, { 1, 2, -3 }, { 3, 2, -1 }, { -1, 3, 1 }, { -1, 3, 0 }, { -1, 3, -1 }, { 0, 3, 1 }, { 0, 3, -1 }, { 1, 3, 1 }, { 1, 3, 0 }, { 1, 3, -1 }, { 2, 3, 1 }, { -2, 3, 1 }, { -2, 3, 0 }, { -2, 3, -1 }, { -1, 3, 2 }, { -1, 3, -2 }, { 0, 3, 2 }, { 0, 3, -2 }, { 2, 3, 0 }, { 2, 3, -1 }, { 1, 3, 2 }, { 1, 3, -2 }, { -3, 3, 0 }, { 3, 3, 0 }, { 0, 3, -3 }, { 0, 3, 3 }, { -2, 3, 2 }, { -2, 3, -2 }, { 2, 3, 2 }, { 2, 3, -2 }, { -3, 3, -1 }, { -3, 3, 1 }, { -1, 3, -3 }, { -1, 3, 3 }, { 1, 3, 3 }, { 3, 3, 1 }, { 1, 3, -3 }, { 3, 3, -1 }, { -1, 4, 1 }, { -1, 4, 0 }, { -1, 4, -1 }, { 0, 4, 1 }, { 0, 4, -1 }, { 1, 4, 1 },
					{ 1, 4, 0 }, { 1, 4, -1 }, { 2, 4, 1 }, { -2, 4, 1 }, { -2, 4, 0 }, { -2, 4, -1 }, { -1, 4, 2 }, { -1, 4, -2 }, { 0, 4, 2 }, { 0, 4, -2 }, { 2, 4, 0 }, { 2, 4, -1 }, { 1, 4, 2 }, { 1, 4, -2 }, { -3, 4, 0 }, { 3, 4, 0 }, { 0, 4, -3 }, { 0, 4, 3 }, { -1, 5, 1 }, { -1, 5, 0 }, { -1, 5, -1 }, { 0, 5, 1 }, { 0, 5, -1 }, { 1, 5, 1 }, { 1, 5, 0 }, { 1, 5, -1 }, { 2, 5, 1 }, { -2, 5, 1 }, { -2, 5, 0 }, { -2, 5, -1 }, { -1, 5, 2 }, { -1, 5, -2 }, { 0, 5, 2 }, { 0, 5, -2 }, { 2, 5, 0 }, { 2, 5, -1 }, { 1, 5, 2 }, { 1, 5, -2 }, { -1, 6, 0 }, { 0, 6, 1 }, { 0, 6, -1 }, { 1, 6, 0 }, { 0, 7, 0 } };

				for (int[] coord : leafPos) {
					BlockPos blockpos = position.add(coord[0], coord[1] + (i - 7), coord[2]);
					state = worldIn.getBlockState(blockpos);
					if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) {
						this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves);
					}
				}

				//MAKE TRUNK
				for (int j3 = 0; j3 < i; ++j3) {
					BlockPos upN = position.up(j3);
					state = worldIn.getBlockState(upN);

					if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) {
						this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood);
						if (j3 == i - 4) {

							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							if (rand.nextBoolean()) {
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
							}

						} else if (j3 == i - 6) {
							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							if (rand.nextBoolean()) {
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
							}
						}
					}
				}

				return true;
			} else {
				return false;
			}
		}
	} else {
		return false;
	}
}
 
Example 17
Project: Got-Wood   File: WorldGenPalm.java   Source Code and License Vote up 4 votes
private boolean generateMini(World worldIn, Random rand, BlockPos position) {
	int i = rand.nextInt(2) + 6;
	boolean flag = true;

	if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) {
		flag = isAreaClear(worldIn, position, i);

		if (!flag) {
			return false;
		}

		//If we can actually make the tree
		else {
			IBlockState state = worldIn.getBlockState(position.down());

			if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) {
				this.setDirtAt(worldIn, position.down());

				//MAKE LEAVES
				final int[][] leafPos = new int[][] { { -1, 0, 1 }, { -1, 0, 0 }, { -1, 0, -1 }, { 0, 0, 1 }, { 0, 0, -1 }, { 1, 0, 1 }, { 1, 0, 0 }, { 1, 0, -1 }, { -1, 1, 1 }, { -1, 1, 0 }, { -1, 1, -1 }, { 0, 1, 1 }, { 0, 1, -1 }, { 0, 1, -2 }, { 1, 1, 1 }, { 1, 1, 0 }, { 1, 1, -1 }, { -1, 1, 0 }, { -1, 1, -1 }, { -2, 1, 1 }, { -2, 1, 0 }, { -2, 1, -1 }, { 2, 1, -1 }, { 2, 1, 0 }, { 2, 1, 1 }, { -1, 1, 2 }, { 0, 1, 2 }, { 1, 1, 2 }, { -1, 1, -2 }, { 1, 1, -2 }, { 1, 1, -2 }, { -1, 2, 1 }, { -1, 2, 0 }, { -1, 2, -1 }, { 0, 2, 1 }, { 0, 2, -1 }, { 1, 2, 1 }, { 1, 2, 0 }, { 1, 2, -1 }, { -2, 2, 0 }, { 2, 2, 0 }, { 0, 2, 2 }, { 0, 2, -2 }, { -1, 3, 1 }, { -1, 3, 0 }, { -1, 3, -1 }, { 0, 3, 1 }, { 0, 3, -1 }, { 1, 3, 1 }, { 1, 3, 0 }, { 1, 3, -1 }, { -1, 4, 0 }, { 0, 4, 1 },
					{ 0, 4, -1 }, { 1, 4, 0 }, { 0, 5, 0 } };

				for (int[] coord : leafPos) {
					BlockPos blockpos = position.add(coord[0], coord[1] + (i - 5), coord[2]);
					state = worldIn.getBlockState(blockpos);
					if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) {
						this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves);
					}
				}
				//MAKE TRUNK
				for (int j3 = 0; j3 < i; ++j3) {
					BlockPos upN = position.up(j3);
					state = worldIn.getBlockState(upN);

					if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) {
						this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood);
						if (j3 == i - 4) {

							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z));
							if (rand.nextBoolean()) {
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
								this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X));
							}

						}
					}
				}

				return true;
			} else {
				return false;
			}
		}
	} else {
		return false;
	}
}
 
Example 18
Project: BaseClient   File: BlockPistonBase.java   Source Code and License Vote up 4 votes
public static boolean canPush(Block blockIn, World worldIn, BlockPos pos, EnumFacing direction, boolean allowDestroy)
{
    if (blockIn == Blocks.obsidian)
    {
        return false;
    }
    else if (!worldIn.getWorldBorder().contains(pos))
    {
        return false;
    }
    else if (pos.getY() >= 0 && (direction != EnumFacing.DOWN || pos.getY() != 0))
    {
        if (pos.getY() <= worldIn.getHeight() - 1 && (direction != EnumFacing.UP || pos.getY() != worldIn.getHeight() - 1))
        {
            if (blockIn != Blocks.piston && blockIn != Blocks.sticky_piston)
            {
                if (blockIn.getBlockHardness(worldIn, pos) == -1.0F)
                {
                    return false;
                }

                if (blockIn.getMobilityFlag() == 2)
                {
                    return false;
                }

                if (blockIn.getMobilityFlag() == 1)
                {
                    if (!allowDestroy)
                    {
                        return false;
                    }

                    return true;
                }
            }
            else if (((Boolean)worldIn.getBlockState(pos).getValue(EXTENDED)).booleanValue())
            {
                return false;
            }

            return !(blockIn instanceof ITileEntityProvider);
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}
 
Example 19
Project: DecompiledMinecraft   File: BiomeGenForest.java   Source Code and License Vote up 4 votes
public void decorate(World worldIn, Random rand, BlockPos pos)
{
    if (this.field_150632_aF == 3)
    {
        for (int i = 0; i < 4; ++i)
        {
            for (int j = 0; j < 4; ++j)
            {
                int k = i * 4 + 1 + 8 + rand.nextInt(3);
                int l = j * 4 + 1 + 8 + rand.nextInt(3);
                BlockPos blockpos = worldIn.getHeight(pos.add(k, 0, l));

                if (rand.nextInt(20) == 0)
                {
                    WorldGenBigMushroom worldgenbigmushroom = new WorldGenBigMushroom();
                    worldgenbigmushroom.generate(worldIn, rand, blockpos);
                }
                else
                {
                    WorldGenAbstractTree worldgenabstracttree = this.genBigTreeChance(rand);
                    worldgenabstracttree.func_175904_e();

                    if (worldgenabstracttree.generate(worldIn, rand, blockpos))
                    {
                        worldgenabstracttree.func_180711_a(worldIn, rand, blockpos);
                    }
                }
            }
        }
    }

    int j1 = rand.nextInt(5) - 3;

    if (this.field_150632_aF == 1)
    {
        j1 += 2;
    }

    for (int k1 = 0; k1 < j1; ++k1)
    {
        int l1 = rand.nextInt(3);

        if (l1 == 0)
        {
            DOUBLE_PLANT_GENERATOR.setPlantType(BlockDoublePlant.EnumPlantType.SYRINGA);
        }
        else if (l1 == 1)
        {
            DOUBLE_PLANT_GENERATOR.setPlantType(BlockDoublePlant.EnumPlantType.ROSE);
        }
        else if (l1 == 2)
        {
            DOUBLE_PLANT_GENERATOR.setPlantType(BlockDoublePlant.EnumPlantType.PAEONIA);
        }

        for (int i2 = 0; i2 < 5; ++i2)
        {
            int j2 = rand.nextInt(16) + 8;
            int k2 = rand.nextInt(16) + 8;
            int i1 = rand.nextInt(worldIn.getHeight(pos.add(j2, 0, k2)).getY() + 32);

            if (DOUBLE_PLANT_GENERATOR.generate(worldIn, rand, new BlockPos(pos.getX() + j2, i1, pos.getZ() + k2)))
            {
                break;
            }
        }
    }

    super.decorate(worldIn, rand, pos);
}
 
Example 20
Project: DecompiledMinecraft   File: BlockPistonBase.java   Source Code and License Vote up 4 votes
public static boolean canPush(Block blockIn, World worldIn, BlockPos pos, EnumFacing direction, boolean allowDestroy)
{
    if (blockIn == Blocks.obsidian)
    {
        return false;
    }
    else if (!worldIn.getWorldBorder().contains(pos))
    {
        return false;
    }
    else if (pos.getY() >= 0 && (direction != EnumFacing.DOWN || pos.getY() != 0))
    {
        if (pos.getY() <= worldIn.getHeight() - 1 && (direction != EnumFacing.UP || pos.getY() != worldIn.getHeight() - 1))
        {
            if (blockIn != Blocks.piston && blockIn != Blocks.sticky_piston)
            {
                if (blockIn.getBlockHardness(worldIn, pos) == -1.0F)
                {
                    return false;
                }

                if (blockIn.getMobilityFlag() == 2)
                {
                    return false;
                }

                if (blockIn.getMobilityFlag() == 1)
                {
                    if (!allowDestroy)
                    {
                        return false;
                    }

                    return true;
                }
            }
            else if (((Boolean)worldIn.getBlockState(pos).getValue(EXTENDED)).booleanValue())
            {
                return false;
            }

            return !(blockIn instanceof ITileEntityProvider);
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}