Java Code Examples for net.minecraft.block.material.Material#GRASS

The following examples show how to use net.minecraft.block.material.Material#GRASS . 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: BlockPepperCrop.java    From Sakura_mod with MIT License 5 votes vote down vote up
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction,
		IPlantable plantable) {
	return state.getMaterial() == Material.GROUND || state.getMaterial() == Material.GRASS
			|| (state.getBlock() instanceof BlockPepperCrop && this.getAge(state) >= 2)
			|| (state.getBlock() instanceof BlockPepperSplint);
}
 
Example 2
Source File: BlockVanillaCrop.java    From Sakura_mod with MIT License 5 votes vote down vote up
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction,
		IPlantable plantable) {
	return state.getMaterial() == Material.GROUND || state.getMaterial() == Material.GRASS
			|| (state.getBlock() instanceof BlockVanillaCrop && this.getAge(state) >= 2)
			|| (state.getBlock() instanceof BlockVanillaSplint);
}
 
Example 3
Source File: BlockAnvil.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public BlockAnvil()
{
	super(Material.GRASS, FACING);
	this.setCreativeTab(TFCTabs.TFCDevices);
	this.isBlockContainer = true;
	setSoundType(SoundType.GROUND);
	this.setBreaksWhenSuspended(true);
}
 
Example 4
Source File: ToolDrillLV.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean canMineBlock(IBlockState block, ItemStack stack) {
    String tool = block.getBlock().getHarvestTool(block);
    return (tool != null && (tool.equals("pickaxe") || tool.equals("shovel"))) ||
        block.getMaterial() == Material.ROCK ||
        block.getMaterial() == Material.IRON ||
        block.getMaterial() == Material.ANVIL ||
        block.getMaterial() == Material.SAND ||
        block.getMaterial() == Material.GRASS ||
        block.getMaterial() == Material.GROUND ||
        block.getMaterial() == Material.SNOW ||
        block.getMaterial() == Material.CLAY ||
        block.getMaterial() == Material.GLASS;
}
 
Example 5
Source File: ToolShovel.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean canMineBlock(IBlockState block, ItemStack stack) {
    String tool = block.getBlock().getHarvestTool(block);
    return (tool != null && tool.equals("shovel")) ||
        block.getMaterial() == Material.SAND ||
        block.getMaterial() == Material.GRASS ||
        block.getMaterial() == Material.GROUND ||
        block.getMaterial() == Material.SNOW ||
        block.getMaterial() == Material.CLAY;
}
 
Example 6
Source File: ToolUniversalSpade.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean canMineBlock(IBlockState block, ItemStack stack) {
    String tool = block.getBlock().getHarvestTool(block);
    return (tool != null && (tool.equals("shovel") ||
        tool.equals("axe") ||
        tool.equals("saw") ||
        tool.equals("sword") ||
        tool.equals("crowbar"))) ||
        block.getMaterial() == Material.SAND ||
        block.getMaterial() == Material.GRASS ||
        block.getMaterial() == Material.GROUND ||
        block.getMaterial() == Material.SNOW ||
        block.getMaterial() == Material.CLAY ||
        block.getMaterial() == Material.CRAFTED_SNOW ||
        block.getMaterial() == Material.LEAVES ||
        block.getMaterial() == Material.VINE ||
        block.getMaterial() == Material.WOOD ||
        block.getMaterial() == Material.CACTUS ||
        block.getMaterial() == Material.CIRCUITS ||
        block.getMaterial() == Material.GOURD ||
        block.getMaterial() == Material.WEB ||
        block.getMaterial() == Material.CLOTH ||
        block.getMaterial() == Material.CARPET ||
        block.getMaterial() == Material.PLANTS ||
        block.getMaterial() == Material.CAKE ||
        block.getMaterial() == Material.TNT ||
        block.getMaterial() == Material.SPONGE;
}
 
Example 7
Source File: GTBedrockOreMineable.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void generateOreFlower(World worldIn, BlockPos blockpos) {
	if (worldIn.rand.nextInt(4) == 0) {
		for (int j = 0; j < 100; ++j) {
			Material material = worldIn.getBlockState(blockpos.offset(EnumFacing.UP, j)).getMaterial();
			if (material == Material.GRASS) {
				BlockPos upPos = blockpos.offset(EnumFacing.UP, j + 1);
				if (worldIn.getBlockState(upPos).getBlock().isReplaceable(worldIn, upPos)) {
					worldIn.setBlockState(upPos, GTBlocks.oreChid.getDefaultState());
				}
				break;
			}
		}
	}
}
 
Example 8
Source File: ItemBroom.java    From Sakura_mod with MIT License 5 votes vote down vote up
/**
    * Called when a Block is right-clicked with this Item
    */
@Override
   public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
   {
       ItemStack itemstack = player.getHeldItem(hand);

       if (!player.canPlayerEdit(pos.offset(facing), facing, itemstack))
       {
           return EnumActionResult.FAIL;
       }
	IBlockState iblockstate = worldIn.getBlockState(pos);
	Block block = iblockstate.getBlock();

	if (facing != EnumFacing.DOWN && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && ((worldIn.getBlockState(pos).getMaterial() == Material.GROUND||worldIn.getBlockState(pos).getMaterial() ==Material.GRASS) && !(block instanceof BlockFarmland||block instanceof BlockGrassPath)))
	{
	    IBlockState iblockstate1 = Blocks.GRASS_PATH.getDefaultState();
	    worldIn.playSound(player, pos, SoundEvents.BLOCK_GRASS_STEP, SoundCategory.BLOCKS, 1.2F, 1.2F);
	    worldIn.playSound(player, pos, SoundEvents.BLOCK_GRASS_PLACE, SoundCategory.BLOCKS, 1.2F, 1.2F);
	    if (!worldIn.isRemote)
	    {
	        worldIn.setBlockState(pos, iblockstate1, 11);
	        itemstack.damageItem(1, player);
	    }

	    return EnumActionResult.SUCCESS;
	}
	return EnumActionResult.PASS;
   }
 
Example 9
Source File: BlockThatch.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public BlockThatch()
{
	super(Material.GRASS, null);
	this.setCreativeTab(TFCTabs.TFCBuilding);
	this.setSoundType(SoundType.PLANT);
	this.lightOpacity = 255;
}
 
Example 10
Source File: BlockTorikkiGrass.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public BlockTorikkiGrass() {
	super("torikki_grass", Material.GRASS);
	setSoundType(SoundType.PLANT);
	setHardness(0.6f);
	setResistance(3.0f);
	setHarvestLevel("shovel", 0);
	setTickRandomly(true);
}
 
Example 11
Source File: BlockSmallVessel.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public BlockSmallVessel()
{
	super(Material.GRASS, null);
	this.setCreativeTab(TFCTabs.TFCBuilding);
	this.isBlockContainer = true;
	setSoundType(SoundType.GROUND);
}
 
Example 12
Source File: BlockAncientDevice.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public BlockAncientDevice()
{
	super(Material.GRASS, null);
	this.setCreativeTab(TFCTabs.TFCDevices);
	this.isBlockContainer = true;
	setSoundType(SoundType.GROUND);
	this.setBreaksWhenSuspended(true);
}
 
Example 13
Source File: BlockCrop.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public BlockCrop()
{
	super(Material.GRASS, GROWTH);
	this.setCreativeTab(TFCTabs.TFCBuilding);
	this.isBlockContainer = true;
	setSoundType(SoundType.GROUND);
}
 
Example 14
Source File: BlockFirepit.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public BlockFirepit()
{
	super(Material.GRASS, LIT);
	this.setCreativeTab(null);
	this.isBlockContainer = true;
	setSoundType(SoundType.GROUND);
	this.setBlockBounds(0, 0, 0, 1, 0.3, 1);
	this.setBreaksWhenSuspended(true);
	this.setLightLevel(0.8f);
}
 
Example 15
Source File: GTTileCharcoalPit.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
private boolean isCovered(BlockPos pos) {
	return world.getBlockState(pos).getMaterial() == Material.GROUND
			|| world.getBlockState(pos).getMaterial() == Material.GRASS
			|| world.getBlockState(pos).getBlock() == GTBlocks.tileCharcoalPit || isLog(pos);
}
 
Example 16
Source File: ItemEnderTool.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean canHarvestBlock(IBlockState state, ItemStack stack)
{
    if (this.isToolBroken(stack))
    {
        return false;
    }

    ToolType tool = ToolType.fromStack(stack);

    if (tool.equals(ToolType.PICKAXE)) // Ender Pickaxe
    {
        if (state.getMaterial() == Material.ROCK
            || state.getMaterial() == Material.GLASS
            || state.getMaterial() == Material.ICE
            || state.getMaterial() == Material.PACKED_ICE
            || state.getMaterial() == Material.REDSTONE_LIGHT
            || state.getMaterial() == Material.PISTON
            || state.getMaterial() == Material.IRON
            || state.getMaterial() == Material.ANVIL)
        {
            //System.out.println("canHarvestBlock(): true; Pickaxe");
            return true;
        }
    }
    else if (tool.equals(ToolType.AXE)) // Ender Axe
    {
        if (state.getMaterial() == Material.WOOD
            || state.getMaterial() == Material.LEAVES
            || state.getMaterial() == Material.GOURD
            || state.getMaterial() == Material.CARPET
            || state.getMaterial() == Material.CLOTH
            || state.getMaterial() == Material.PLANTS
            || state.getMaterial() == Material.VINE)
        {
            //System.out.println("canHarvestBlock(): true; Axe");
            return true;
        }
    }
    else if (tool.equals(ToolType.SHOVEL)) // Ender Shovel
    {
        if (state.getMaterial() == Material.GROUND
            || state.getMaterial() == Material.GRASS
            || state.getMaterial() == Material.SAND
            || state.getMaterial() == Material.SNOW
            || state.getMaterial() == Material.CRAFTED_SNOW
            || state.getMaterial() == Material.CLAY)
        {
            //System.out.println("canHarvestBlock(): true; Shovel");
            return true;
        }
    }

    //System.out.println("canHarvestBlock(): false");
    return false;
}
 
Example 17
Source File: GTBlockOreFlower.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
	IBlockState soil = worldIn.getBlockState(pos.down());
	return super.canPlaceBlockAt(worldIn, pos)
			&& (soil.getMaterial() == Material.GRASS || soil.getMaterial() == Material.GROUND);
}
 
Example 18
Source File: BlockPepperSplint.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
	// TODO Auto-generated method stub
	return worldIn.getBlockState(pos.down()).getMaterial()==Material.GROUND||worldIn.getBlockState(pos.down()).getMaterial()==Material.GRASS
			||worldIn.getBlockState(pos.down()).getBlock()==BlockLoader.PEPPER_SPLINT||worldIn.getBlockState(pos.down()).getBlock()==BlockLoader.PEPPERCROP;
}
 
Example 19
Source File: BlockVanillaSplint.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
	return worldIn.getBlockState(pos.down()).getMaterial()==Material.GROUND||worldIn.getBlockState(pos.down()).getMaterial()==Material.GRASS
			||worldIn.getBlockState(pos.down()).getBlock()==BlockLoader.VANILLA_SPLINT||worldIn.getBlockState(pos.down()).getBlock()==BlockLoader.VANILLACROP;
}