Java Code Examples for net.minecraft.block.material.Material#leaves()

The following examples show how to use net.minecraft.block.material.Material#leaves() . 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
@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 2
protected void Process(World world, TreeConfig tc, Schematic schem, BlockPos blockPos, IBlockState state, Center c)
{
	if(state.getBlock().getMaterial(state) == Material.WOOD)
	{
		if(world.getBlockState(blockPos).getBlock().isReplaceable(world, blockPos) || (replaceSoil && Core.isSoil(world.getBlockState(blockPos))))
			world.setBlockState(blockPos, tc.wood, 2);
	}
	else if(state.getBlock().getMaterial(state) == Material.LEAVES)
	{
		if(world.getBlockState(blockPos).getBlock().isReplaceable(world, blockPos))
		{
			world.setBlockState(blockPos, tc.leaves, 2);
		}
	}
	else
	{
		world.setBlockState(blockPos, state, 2);
	}
}
 
Example 3
Source Project: TFC2   File: BlockSapling.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void Process(World world, BlockPos blockPos, TreeConfig tc,
		Schematic schem, IBlockState state)
{

	IBlockState block = tc.wood;
	IBlockState leaves = tc.leaves;

	if(state.getBlock().getMaterial(state) == Material.WOOD)
	{
		world.setBlockState(blockPos, block, 2);
	}
	else if(state.getBlock().getMaterial(state) == Material.LEAVES)
	{
		if(world.getBlockState(blockPos).getBlock().isReplaceable(world, blockPos))
		{
			world.setBlockState(blockPos, leaves, 2);
		}
	}
	else
	{
		world.setBlockState(blockPos, state);
	}
}
 
Example 4
@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 5
Source Project: Sakura_mod   File: ItemKotachi.java    License: 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 6
Source Project: Sakura_mod   File: ItemKatana.java    License: 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 7
@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 8
@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 9
@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
@Override
public boolean canMineBlock(IBlockState block, ItemStack stack) {
    String tool = block.getBlock().getHarvestTool(block);
    return (tool != null && (tool.equals("axe") || tool.equals("saw"))) ||
        block.getMaterial() == Material.LEAVES ||
        block.getMaterial() == Material.VINE ||
        block.getMaterial() == Material.WOOD ||
        block.getMaterial() == Material.CACTUS ||
        block.getMaterial() == Material.ICE ||
        block.getMaterial() == Material.PACKED_ICE;
}
 
Example 11
Source Project: TFC2   File: BlockLeaves.java    License: GNU General Public License v3.0 5 votes vote down vote up
public BlockLeaves()
{
	super(Material.LEAVES, null);
	this.setCreativeTab(null);
	this.setHardness(0.2F);
	this.setLightOpacity(1);
	this.META_PROP = META_PROPERTY;
	setSoundType(SoundType.PLANT);
	this.setTickRandomly(true);
	this.setShowInCreative(false);
}
 
Example 12
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase livingBase)
{
    //System.out.println("onBlockDestroyed(): living: " + living + " remote: " + living.worldObj.isRemote);

    if ((livingBase instanceof EntityPlayer) && this.isCreativeLikeBreakingEnabled(stack))
    {
        ((EntityPlayer) livingBase).getCooldownTracker().setCooldown(this, 6);
    }

    // Don't use durability for breaking leaves with an axe
    if (state.getMaterial() == Material.LEAVES && ToolType.fromStack(stack).equals(ToolType.AXE))
    {
        return false;
    }

    // Don't use durability on instant-minable blocks (hardness == 0.0f), or if the tool is already broken
    if (this.isToolBroken(stack) == false && state.getBlockHardness(world, pos) > 0.0f)
    {
        // Fast mode uses double the durability, but not while using the Creative Breaking upgrade
        int dmg = (PowerStatus.fromStack(stack) == PowerStatus.POWERED && this.isCreativeLikeBreakingEnabled(stack) == false ? 2 : 1);
        this.addToolDamage(stack, dmg, livingBase, livingBase);
        return true;
    }

    return false;
}
 
Example 13
@Override
public boolean canMineBlock(IBlockState block, ItemStack stack) {
    return block.getMaterial() == Material.LEAVES;
}
 
Example 14
@Override
public float getDestroySpeed(ItemStack stack, IBlockState state)
{
    if (this.isToolBroken(stack))
    {
        return 0.2f;
    }

    ToolType tool = ToolType.fromStack(stack);

    if (this.isCreativeLikeBreakingEnabled(stack) &&  this.canHarvestBlock(state, stack))
    {
        return 1600f;
    }

    // Allow instant mine of leaves with the axe
    if (state.getMaterial() == Material.LEAVES && tool.equals(ToolType.AXE))
    {
        // This seems to be enough to instant mine leaves even when jumping/flying
        return 100.0f;
    }

    float eff = this.efficiencyOnProperMaterial;
    // 34 is the minimum to allow instant mining with just Efficiency V (= no beacon/haste) on cobble,
    // 124 is the minimum for iron blocks @ hardness 5.0f (which is about the highest of "normal" blocks), 1474 on obsidian.
    // So maybe around 160 might be ok? I don't want insta-mining on obsidian, but all other types of "rock".
    if (PowerStatus.fromStack(stack) == PowerStatus.POWERED)
    {
        if (EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByLocation("efficiency"), stack) >= 5)
        {
            eff = 124.0f;
        }
        // This is enough to give instant mining for sandstone and netherrack without any Efficiency enchants.
        else
        {
            eff = 24.0f;
        }
    }

    //if (ForgeHooks.isToolEffective(stack, block, meta))
    if (state.getBlock().isToolEffective(tool.getToolClass(), state))
    {
        //System.out.println("getStrVsBlock(); isToolEffective() true: " + eff);
        return eff;
    }

    if (this.canHarvestBlock(state, stack))
    {
        //System.out.println("getStrVsBlock(); canHarvestBlock() true: " + eff);
        return eff;
    }

    //System.out.println("getStrVsBlock(); not effective: " + super.getStrVsBlock(stack, block, meta));
    return super.getDestroySpeed(stack, state);
}
 
Example 15
@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 16
private boolean isOnLeaves() {
  IBlockState bs = entity.getEntityWorld().getBlockState(entity.getPosition().down());
  return bs.getMaterial() == Material.LEAVES;
}
 
Example 17
private boolean isOnLeaves() {
  IBlockState bs = entity.getEntityWorld().getBlockState(entity.getPosition().down());
  return bs.getMaterial() == Material.LEAVES;
}
 
Example 18
@Override
public float getBlockPathWeight(BlockPos pos) {
  IBlockState bs = world.getBlockState(pos.down());
  return bs.getMaterial() == Material.LEAVES ? 10.0F : 0;
}
 
Example 19
private boolean isOnLeaves() {
  IBlockState bs = world.getBlockState(getPosition().down());    
  return bs.getMaterial() == Material.LEAVES;
}