ItemShears .java

net.minecraft.item.ItemShears (class, 49 lines): extends Item. members: onBlockDestroyed, canHarvestBlock, getStrVsBlock. imports: CreativeTabs.

net.minecraft.itemclass49 linescommonextends Item1.6 KB

API Surface (3)

boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn)
boolean canHarvestBlock(Block blockIn)
float getStrVsBlock(ItemStack stack, Block state)

Full Source

ItemShears.java49 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.item;
2
3
import net.minecraft.block.Block;
4
import net.minecraft.block.material.Material;
5
import net.minecraft.creativetab.CreativeTabs;
6
import net.minecraft.entity.EntityLivingBase;
7
import net.minecraft.init.Blocks;
8
import net.minecraft.util.BlockPos;
9
import net.minecraft.world.World;
10
11
public class ItemShears extends Item
12
{
13
    public ItemShears()
14
    {
15
        this.setMaxStackSize(1);
16
        this.setMaxDamage(238);
17
        this.setCreativeTab(CreativeTabs.tabTools);
18
    }
19
20
    /**
21
     * Called when a Block is destroyed using this Item. Return true to trigger the "Use Item" statistic.
22
     */
23
    public boolean onBlockDestroyed(ItemStack stack, World worldIn, Block blockIn, BlockPos pos, EntityLivingBase playerIn)
24
    {
25
        if (blockIn.getMaterial() != Material.leaves && blockIn != Blocks.web && blockIn != Blocks.tallgrass && blockIn != Blocks.vine && blockIn != Blocks.tripwire && blockIn != Blocks.wool)
26
        {
27
            return super.onBlockDestroyed(stack, worldIn, blockIn, pos, playerIn);
28
        }
29
        else
30
        {
31
            stack.damageItem(1, playerIn);
32
            return true;
33
        }
34
    }
35
36
    /**
37
     * Check whether this Item can harvest the given Block
38
     */
39
    public boolean canHarvestBlock(Block blockIn)
40
    {
41
        return blockIn == Blocks.web || blockIn == Blocks.redstone_wire || blockIn == Blocks.tripwire;
42
    }
43
44
    public float getStrVsBlock(ItemStack stack, Block state)
45
    {
46
        return state != Blocks.web && state.getMaterial() != Material.leaves ? (state == Blocks.wool ? 5.0F : super.getStrVsBlock(stack, state)) : 15.0F;
47
    }
48
}
49

Deobfuscated MCP 1.8.9 source of ItemShears from Marcelektro/MavenMCP-1.8.9 (net/minecraft/item/ItemShears.java), stored verbatim.