Fabric API

Fabric API

106M Downloads

Strength/Hardness/Resistance being set improperly high on blocks with custom class

skylorbeck opened this issue ยท 8 comments

commented

I have a several custom blocks that all mine 10x+ slower than the block that they copy the settings of. None of the classes touch the settings at all, simply passing it to their super.

public CompressedBlock(Settings settings,int level) {
        super(settings);
        this.setDefaultState(this.getDefaultState().with(compression,level));
    }
    public static final Block monuple_compressed_cobblestone_block = new CompressedBlock(FabricBlockSettings.copyOf(Blocks.COBBLESTONE), 1);

This is an example of one of the blocks. When mining it breaks as slow as obsidian. I tried this as well (copied straight from vanilla minecraft code)

 public static final Block monuple_compressed_cobblestone_block = new CompressedBlock(AbstractBlock.Settings.of(Material.STONE).requiresTool().strength(2.0F, 6.0F), 1);

and it had the same result.
Testing it by changing it to a vanilla class, like HayBlock, did work however. Then it would copy all of the settings of the block and break at the appropriate speed, however I lose my custom functionality.

Would love for someone to tell me that I'm dumb and what I did wrong, but this system worked fine with 1.16.4

commented

If you are using 1.17, you must also add your block to the proper mineable tag.

commented

Well butter my biscuit. Thank you very much.

commented

Alright after an hour of messing with that, it's still not working. The tag is loading properly and my items are in it, but still they break slowly.

commented

Are you adding to an item tag or a block tag? The mineable tags are block tags.

commented

Block tag,
image

commented

Thanks for helping so quickly btw, this has been stumping me all day.

commented

Alright I solved it. Minecraft tag jsons don't matter. You have to append .breakByTool(FabricToolTags.PICKAXES) to the registration.

public static final Block monuple_compressed_cobblestone_block = new CompressedBlock(FabricBlockSettings.copyOf(Blocks.COBBLESTONE), 1);

what I was doing

public static final Block monuple_compressed_cobblestone_block = new CompressedBlock(FabricBlockSettings.copyOf(Blocks.COBBLESTONE).breakByTool(FabricToolTags.PICKAXES), 1);

what works

The Json file seems to matter for... well I don't know what it would matter for actually. Doesn't make a bit of a difference here.

commented

BTW if anyone else was wondering, you still have to add your tools to the tag in fabric/tags/items for it to work