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

The following examples show how to use net.minecraft.block.material.Material#PLANTS . 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: ItemEnderSword.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public float getDestroySpeed(ItemStack stack, IBlockState state)
{
    if (this.isToolBroken(stack))
    {
        return 0.2f;
    }

    if (state.getBlock() == Blocks.WEB)
    {
        return 15.0f;
    }

    Material material = state.getMaterial();

    if (material == Material.PLANTS ||
        material == Material.VINE ||
        material == Material.CORAL ||
        material == Material.LEAVES ||
        material == Material.GOURD)
    {
        return 1.5f;
    }

    return 1.0f;
}
 
Example 2
Source File: ToolSword.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean canMineBlock(IBlockState block, ItemStack stack) {
    String tool = block.getBlock().getHarvestTool(block);
    return (tool != null && tool.equals("sword")) ||
        block.getMaterial() == Material.LEAVES ||
        block.getMaterial() == Material.GOURD ||
        block.getMaterial() == Material.VINE ||
        block.getMaterial() == Material.WEB ||
        block.getMaterial() == Material.CLOTH ||
        block.getMaterial() == Material.CARPET ||
        block.getMaterial() == Material.PLANTS ||
        block.getMaterial() == Material.CACTUS ||
        block.getMaterial() == Material.CAKE ||
        block.getMaterial() == Material.TNT ||
        block.getMaterial() == Material.SPONGE;
}
 
Example 3
Source File: WorldGenBamboo.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public boolean generate(World worldIn, Random rand, BlockPos position) {
    int i = 9 + rand.nextInt(9);

    for (int i2 = 0; i2 < i; ++i2) {
        BlockPos blockpos = position.up(i2);
        if ((BlockLoader.BAMBOOSHOOT.canBlockStay(worldIn, blockpos)||
        		worldIn.getBlockState(blockpos.down()).getBlock() instanceof BlockPlantBamboo) && 
        (worldIn.isAirBlock(blockpos) || 
        		worldIn.getBlockState(blockpos).getMaterial() == Material.PLANTS
        		&& !(worldIn.getBlockState(blockpos).getBlock() instanceof BlockLeaves))) {
            worldIn.setBlockState(blockpos, BlockLoader.BAMBOO.getDefaultState(), 2);
        }
    }
    return true;
}
 
Example 4
Source File: ToolSense.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockPreBreak(ItemStack stack, BlockPos blockPos, EntityPlayer player) {
    if (player.world.isRemote || player.capabilities.isCreativeMode) {
        return false;
    }
    ToolMetaItem<?> toolMetaItem = (ToolMetaItem<?>) stack.getItem();
    int damagePerBlockBreak = getToolDamagePerBlockBreak(stack);
    for(int x = -5; x <= 5; x++) {
        for(int z = -5; z <= 5; z++) {
            for(int y = -5; y <= 5; y++) {BlockPos offsetPos = blockPos.add(x, y, z);
                IBlockState blockState = player.world.getBlockState(offsetPos);
                if(player.world.isBlockModifiable(player, offsetPos) && toolMetaItem.isUsable(stack, damagePerBlockBreak)) {
                    if(blockState.getBlock() instanceof BlockCrops) {

                        player.world.playEvent(2001, offsetPos, Block.getStateId(blockState));
                        ToolUtility.applyHarvestBehavior(offsetPos, player);
                        toolMetaItem.damageItem(stack, damagePerBlockBreak, false);

                    } else if(blockState.getMaterial() == Material.PLANTS ||
                        blockState.getMaterial() == Material.LEAVES ||
                        blockState.getMaterial() == Material.VINE) {

                        player.world.playEvent(2001, offsetPos, Block.getStateId(blockState));
                        player.world.setBlockToAir(offsetPos);
                        toolMetaItem.damageItem(stack, damagePerBlockBreak, false);
                    }
                }

            }
        }
    }
    return true;
}
 
Example 5
Source File: BlockCrop.java    From AgriCraft with MIT License 5 votes vote down vote up
public BlockCrop() {
    super("crop", Material.PLANTS);
    this.setTickRandomly(true);
    this.hasTileEntity = true;
    this.setSoundType(SoundType.PLANT);
    this.setHardness(0.0F);
    //this.disableStats();
    this.setCreativeTab(null);
}
 
Example 6
Source File: BlockSapling.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
protected BlockSapling(PropertyHelper ph)
{
	super(Material.PLANTS, ph);
	this.setCreativeTab(TFCTabs.TFCDecoration);
	setSoundType(SoundType.GROUND);
	this.setTickRandomly(true);
}
 
Example 7
Source File: BlockWaterHyacinth.java    From Production-Line with MIT License 5 votes vote down vote up
public BlockWaterHyacinth() {
    super(Material.PLANTS);
    this.setUnlocalizedName("productionline.block.WaterHyacinth");
    this.setCreativeTab(creativeTabPL);
    //this.setBlockTextureName(ProductionLine.RESOURCE_DOMAIN + ":" + "BlockWaterHyacinth");
    this.setHardness(0.0F);
    this.setResistance(0.0F);
    this.setSoundType(SoundType.PLANT);
    this.setTickRandomly(true);
}
 
Example 8
Source File: GTBlockOreFlower.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public GTBlockOreFlower(String name, int id) {
	super(Material.PLANTS);
	this.name = name;
	this.id = id;
	setRegistryName(this.name.toLowerCase());
	setUnlocalizedName(GTMod.MODID + "." + this.name.toLowerCase());
	setCreativeTab(GTMod.creativeTabGT);
	setHardness(0.8F);
	setResistance(0.2F);
	setSoundType(SoundType.PLANT);
	setHarvestLevel("axe", 0);
	if (id == 39) {
		this.setLightLevel(3.0F);
	}
}
 
Example 9
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 10
Source File: ToolSense.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) {
    return block.getMaterial() == Material.PLANTS ||
        block.getMaterial() == Material.LEAVES ||
        block.getMaterial() == Material.VINE ||
        block.getBlock() instanceof BlockCrops;
}
 
Example 11
Source File: ShreddedStarchBlock.java    From EmergingTechnology with MIT License 5 votes vote down vote up
public ShreddedStarchBlock() {
  super(Material.PLANTS);
  this.setHardness(1.0f);
  this.setRegistryName(EmergingTechnology.MODID, _name);
  this.setUnlocalizedName(EmergingTechnology.MODID + "." + _name);
  this.setCreativeTab(EmergingTechnology.TECHNOLOGYTAB);
  this.setSoundType(SoundType.PLANT);
}
 
Example 12
Source File: ShreddedPlantBlock.java    From EmergingTechnology with MIT License 5 votes vote down vote up
public ShreddedPlantBlock() {
  super(Material.PLANTS);
  this.setHardness(1.0f);
  this.setRegistryName(EmergingTechnology.MODID, _name);
  this.setUnlocalizedName(EmergingTechnology.MODID + "." + _name);
  this.setCreativeTab(EmergingTechnology.TECHNOLOGYTAB);
  this.setSoundType(SoundType.PLANT);
}
 
Example 13
Source File: ItemKatana.java    From Sakura_mod with MIT License 5 votes vote down vote up
public float getDestroySpeed(ItemStack stack, IBlockState state) {
      Block block = state.getBlock();

      if (block == Blocks.WEB) {
          return 15.0F;
      }
Material material = state.getMaterial();
return material != Material.PLANTS && material != Material.VINE && material != Material.CORAL && material != Material.LEAVES && material != Material.GOURD ? 1.0F : 1.5F;
  }
 
Example 14
Source File: ItemKotachi.java    From Sakura_mod with MIT License 5 votes vote down vote up
public float getDestroySpeed(ItemStack stack, IBlockState state) {
      Block block = state.getBlock();

      if (block == Blocks.WEB) {
          return 15.0F;
      }
Material material = state.getMaterial();
return material != Material.PLANTS && material != Material.VINE && material != Material.CORAL && material != Material.LEAVES && material != Material.GOURD ? 1.0F : 1.5F;
  }
 
Example 15
Source File: BlockChestnut.java    From Sakura_mod with MIT License 4 votes vote down vote up
public BlockChestnut() {
	super(Material.PLANTS);
	this.setTickRandomly(true);
	setSoundType(SoundType.WOOD);
	this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, 0));
}
 
Example 16
Source File: BlockBambooShoot.java    From Sakura_mod with MIT License 4 votes vote down vote up
public BlockBambooShoot() {
    super(Material.PLANTS);
    this.setTickRandomly(true);
    this.setCreativeTab(CommonProxy.tab);
    this.setResistance(2.0F);
}
 
Example 17
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;
}