Java Code Examples for net.minecraft.init.Blocks#SOUL_SAND

The following examples show how to use net.minecraft.init.Blocks#SOUL_SAND . 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: TofuCraftReload   File: ItemSoybeansNether.java    License: MIT License 5 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
    ItemStack item = playerIn.getHeldItem(hand);

    if(item.getItem() == this &&!item.isEmpty()) {
        if (side != EnumFacing.UP) {
            return EnumActionResult.PASS;
        } else if (playerIn.canPlayerEdit(pos, side, item) && playerIn.canPlayerEdit(pos.up(), side, item)) {
            IBlockState soil = worldIn.getBlockState(pos);

            if (soil != null && worldIn.isAirBlock(pos.up())) {
                boolean isPlanted = false;

                if (soil.getBlock() == BlockLoader.TOFUFARMLAND||soil.getBlock()==Blocks.SOUL_SAND) {
                    worldIn.setBlockState(pos.up(), BlockLoader.SOYBEAN_NETHER.getDefaultState());
                    isPlanted = true;
                }

                if (isPlanted) {
                    item.shrink(1);
                    return EnumActionResult.SUCCESS;
                } else {
                    return EnumActionResult.PASS;
                }
            } else {
                return EnumActionResult.PASS;
            }
            //return EnumActionResult.PASS;
        }
        return EnumActionResult.PASS;
    }
    else
    {
        return EnumActionResult.PASS;
    }
}
 
Example 2
public boolean generate(World world, Random rand, BlockPos position)
{
	while (world.isAirBlock(position) && position.getY() > 2)
	{
		position = position.down();
	}

	int i = rand.nextInt(1 +(this.width - 2)) + 2;
	int offset = -2 + rand.nextInt(4);
	if(world.getBlockState(position.down()).getBlock() == Blocks.LAVA)
		position = position.down();

	for (int x = position.getX() - i; x <= position.getX() + i; ++x)
	{
		for (int z = position.getZ() - i; z <= position.getZ() + i; ++z)
		{
			int xx = x - position.getX();
			int zz = z - position.getZ();

			boolean doPlace = xx * xx + zz * zz <= i * i || rand.nextInt(3) == 0;

			if (doPlace)
			{
				for (int yy = position.getY() - 1; yy <= position.getY() + offset; ++yy)
				{
					BlockPos blockpos = new BlockPos(x, yy, z);
					Block block = world.getBlockState(blockpos).getBlock();

					if (block == Blocks.LAVA || block == Blocks.NETHERRACK || block == Blocks.AIR || block == Blocks.SOUL_SAND)
					{
						world.setBlockState(blockpos, this.block.getDefaultState(), 2);
					}
				}
			}
		}
	}

	return true;
}
 
Example 3
Source Project: TFC2   File: BlockTerra.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Determines if this block can support the passed in plant, allowing it to be planted and grow.
 * Some examples:
 *   Reeds check if its a reed, or if its sand/dirt/grass and adjacent to water
 *   Cacti checks if its a cacti, or if its sand
 *   Nether types check for soul sand
 *   Crops check for tilled soil
 *   Caves check if it's a solid surface
 *   Plains check if its grass or dirt
 *   Water check if its still water
 *
 * @param world The current world
 * @param pos Block position in world
 * @param direction The direction relative to the given position the plant wants to be, typically its UP
 * @param plantable The plant that wants to check
 * @return True to allow the plant to be planted/stay.
 */
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable)
{
	IBlockState plant = plantable.getPlant(world, pos.offset(direction));
	net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));

	/*if (plantable instanceof BlockBush)
	{
		return true;
	}*/

	switch (plantType)
	{
	case Desert: return this == TFCBlocks.Sand || this == net.minecraft.init.Blocks.HARDENED_CLAY || this == net.minecraft.init.Blocks.STAINED_HARDENED_CLAY || this == TFCBlocks.Dirt;
	case Nether: return this == Blocks.SOUL_SAND;
	case Crop:   return this == TFCBlocks.Farmland;
	case Cave:   return isSideSolid(state, world, pos, EnumFacing.UP);
	case Plains: return this == TFCBlocks.Grass || this == TFCBlocks.Dirt || this == TFCBlocks.Farmland;
	case Water:  return getMaterial(state) == Material.WATER && ((Integer)state.getValue(BlockLiquid.LEVEL)) == 0;
	case Beach:
		boolean isBeach = this == TFCBlocks.Grass || this == TFCBlocks.Dirt || this == TFCBlocks.Sand;
		boolean hasWater = (world.getBlockState(pos.east()).getBlock().getMaterial(world.getBlockState(pos.east())) == Material.WATER ||
				world.getBlockState(pos.west()).getBlock().getMaterial(world.getBlockState(pos.west())) == Material.WATER ||
				world.getBlockState(pos.north()).getBlock().getMaterial(world.getBlockState(pos.north())) == Material.WATER ||
				world.getBlockState(pos.south()).getBlock().getMaterial(world.getBlockState(pos.south())) == Material.WATER);
		return isBeach && hasWater;
	}

	return false;
}
 
Example 4
Source Project: TofuCraftReload   File: BlockSoybeanNether.java    License: MIT License 4 votes vote down vote up
protected boolean canSustainBush(IBlockState state) {
    return state.getBlock() == Blocks.SOUL_SAND;
}