Natural Progression

Natural Progression

229k Downloads

[1.15.2] Mod Interaction - Kubejs

TheUntamed opened this issue ยท 7 comments

commented

When the Harvestlevel and/or the mining Tool for a block is changed by a mod (e.g. kubejs) this mod still wants the old tool.
As example this screenshot:
Screenshot_41
It should be able to mine the stone with an axe, even with the hand, because the harvestlevel is 0.

commented

Hi,

I'm sorry, I was so busy the last month that I totally forgot this. I came back to this issue because I created a mod that adds blocks of material sand with a harvest level and it had the same problems as described above.
This weekend I tested a lot with your mod and the new commit you pushed to fix it.
Sadly the problem seems to be embedded deep down in the core of minecraft.
If a block of a material that has not the pickaxe as harvesttool (e.g. sand) and you give that block a harvestlevel, it is not treated as a block of that material anymore and also .canHarvestBlock() returns false for a shovel. Something about harvestlevels in combination with shovel or axe is completely broken. I hope mojang will fix that in the future.
But for now event.setCanceled(true); inside your StoneBreak class is always called for a block with harvestlevel of any material and any tooltype.
Most of the time that shouldn't be a problem. In my case it would be neat if you could add a boolean config value and wrap the whole content of your StoneBreak event in an if(conf value) statement.

PS: in the Use ItemStack#canHarvestBlock() instead of tooltype commit wood breaking is broken. Maybe (but im not sure) due to the
event.getPlayer().getHeldItemMainhand().canHarvestBlock(event.getState())
change. If that's the case I think you can just revert this change cause it didn't help anyway.

commented

Huh ok, I'll look into other ways to implement this then. I can imagine where this is an issue it was just unexpected behavior!

commented

Ok I think I've fixed it but I've still got to test it! I'll let you know how that goes :)

commented

Can you post your KubeJS script? I have no idea how to use KubeJS enough to change a block's harvest tool.

commented

You have to create these 2 files inside your kubejs/startup folder:

Screenshot_1

Screenshot_2

Notice that one file is a .js and one is a .json file.

commented

I did exactly what you have here (other than changing the json o use myharvestlevels.js instead of mytooltips.js) and I cannot get this to work. I'll just have to upload the new release and have you test it and see if it works?

commented

oh yeah my fault it should be myharvestlevels.
Yes I can test it.