Jump to content

[1.10.2]ItemTool sets HarvestLevel >=3 pickaxe can't harvest Bricks?


Recommended Posts

Posted (edited)

Hey, guys! I just create a simple tool:

public class NewTool extends ItemTool
{
    
    public NewTool()
    {
        super(3.0f, -1.5f, ToolMaterial.DIAMOND, new HashSet());
        this.setHarvestLevel("pickaxe", 3);
        this.setHarvestLevel("shovel", 3);
    }
}

But I found it can't harvest bricks!

I check the ItemPickaxe code, I found it needs to overwrite canHarvestBlock.

So I do this:

@Override
public boolean canHarvestBlock(IBlockState blockIn)
{
	return true;
}

Now it worked! Bricks can be harvested.

 

I set a debug point to canHarvestBlock().

Only harvesting bricks it triggered.

 

So, is this a bug that Forge missing to take control bricks?

Or it's design that needs canHarvestBlock() to control bricks?

 

Otherwise, is it OK to transfer new HashSet()  for effectiveBlocksIn when I using Forge? (The fourth parameter) It seems no probrem when I do the test in game.

super(3.0f, -1.5f, ToolMaterial.DIAMOND, new HashSet());

 

Forge version: 12.18.3.2422

Thanks!

Edited by raiwhiz
Posted
3 hours ago, raiwhiz said:

new HashSet()

This is your problem. If you look at ItemPickaxe you will see it contains a private static final Set that it uses to determine what blocks it can mine.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
20 minutes ago, Animefan8888 said:

This is your problem. If you look at ItemPickaxe you will see it contains a private static final Set that it uses to determine what blocks it can mine.

Actually, I had tried to copy the private static final Set and add all bricks in it. But nothing chage.

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.BRICK_BLOCK,
                    Blocks.BRICK_STAIRS,
                    Blocks.RED_NETHER_BRICK,
                    Blocks.NETHER_BRICK,
                    Blocks.NETHER_BRICK_STAIRS,
                    Blocks.STONE_BRICK_STAIRS,
                    Blocks.STONEBRICK
            }
    );
public class NewTool extends ItemTool
{
    
    public NewTool()
    {
        super(3.0f, -1.5f, ToolMaterial.DIAMOND, EFFECTIVE_ON);
        this.setHarvestLevel("pickaxe", 3);
        this.setHarvestLevel("shovel", 3);
    }
}

 

Posted
5 minutes ago, raiwhiz said:

Actually, I had tried to copy the private static final Set and add all bricks in it. But nothing chage.

It might just be easier to extend ItemPickaxe instead of ItemTool, unless you want to override all of the methods ItemPickaxe does and put them in your class...

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.