Jump to content

specific tool for a drop


Scrobatto Studios

Recommended Posts

im trying to make a java class for a block, that if you mine it with a hammer it gives you a shard instead of the but, but the code i have its not working rn :c

public class BauxiteOreBlock extends Block {

    public BauxiteOreBlock() {
        super(BlockBehaviour.Properties.of().strength(1.5f, 4.0f).requiresCorrectToolForDrops());
    }

    @Override
    public void playerDestroy(Level level, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, @Nullable ItemStack stack) {
        if (stack.getItem() == ModItems.HAMMER.get()) {
            popResource(level, pos, new ItemStack(ModItems.BAUXITESHARD.get()));
        } else {
            super.playerDestroy(level, player, pos, state, blockEntity, stack);
        }
    }
}

 

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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