Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Multitool extends ItemPickaxe {
- public Item repairItem;
- public Multitool(ToolMaterial material, Item repairItem) {
- super(material);
- this.repairItem = repairItem;
- }
- @Override
- public Set<String> getToolClasses(ItemStack itemStack) {
- return ImmutableSet.of("pickaxe", "axe", "spade", "hoe", "shovel");
- }
- private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(new Block[] { Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE,
- Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE,
- Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE,
- Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE,
- Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE,
- Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON,
- Blocks.STONE_PRESSURE_PLATE, Blocks.PLANKS, Blocks.BOOKSHELF, Blocks.LOG, Blocks.LOG2, Blocks.CHEST,
- Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK, Blocks.LADDER, Blocks.WOODEN_BUTTON,
- Blocks.WOODEN_PRESSURE_PLATE, Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL,
- Blocks.MYCELIUM, Blocks.SAND, Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND, Blocks.GRASS_PATH});
- protected void func_185071_a(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state) {
- worldIn.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
- if (!worldIn.isRemote) {
- worldIn.setBlockState(pos, state, 11);
- stack.damageItem(1, player);
- }
- }
- @Override
- @SuppressWarnings("incomplete-switch")
- public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos,
- EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
- if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) {
- return EnumActionResult.FAIL;
- } else {
- int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(stack, playerIn, worldIn, pos);
- if (hook != 0)
- return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
- IBlockState iblockstate = worldIn.getBlockState(pos);
- Block block = iblockstate.getBlock();
- if (facing != EnumFacing.DOWN && worldIn.isAirBlock(pos.up())) {
- if (block == Blocks.GRASS || block == Blocks.GRASS_PATH) {
- this.func_185071_a(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState());
- return EnumActionResult.SUCCESS;
- }
- if (block == Blocks.DIRT) {
- switch ((BlockDirt.DirtType) iblockstate.getValue(BlockDirt.VARIANT)) {
- case DIRT:
- this.func_185071_a(stack, playerIn, worldIn, pos, Blocks.FARMLAND.getDefaultState());
- return EnumActionResult.SUCCESS;
- case COARSE_DIRT:
- this.func_185071_a(stack, playerIn, worldIn, pos,
- Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
- return EnumActionResult.SUCCESS;
- }
- }
- }
- return EnumActionResult.PASS;
- }
- }
- public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
- return repair.getItem() == repairItem ? true : super.getIsRepairable(toRepair, repair);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment