Custom tool isn't damaged when breaking blocks
ChiriVulpes opened this issue ยท 3 comments
val tool = VanillaFactory.createItem("pickaxe_ruby") as Item;
tool.maxStackSize = 1;
tool.maxDamage = 1000;
tool.toolClass = "pickaxe";
tool.toolLevel = 4;
tool.itemDestroySpeed = function (item, block) {
return 6 as float;
};
tool.register();
The tooltip shows that the tool has 1000 durability, but it doesn't damage the item when breaking a block. I attempted to use Item.itemDestroyBlock
to no avail:
tool.itemDestroyedBlock = function (stack, world, blockstate, pos, entity) {
stack.damageItem(1, entity);
return true;
};
Is there another way to do this that I'm missing, or am I doing something wrong?
That's probably erroring! it's stack.damage I believe. The documentation has yet to be corrected!
That's interesting, it's actually silently failing. From how many errors I've gotten when wrapping my head around this api, I'm very surprised to see a silent error.
tool.itemDestroyedBlock = function (stack, world, blockstate, pos, entity) {
stack.damageItem(1, entity);
print("test");
return true;
};
Relevant text (added when breaking a block) in crafttweaker.log
:
[SERVER_STARTED][CLIENT][INFO] test
[SERVER_STARTED][SERVER][INFO] test
The IMutableItemStack documentation has it correct, but I was actually copying from the example in IItemUse which is a separate type.