Allow for the funcion system to modify stacks in player's inventory
Fiaegel opened this issue ยท 1 comments
In the current version (4.1.0) there is no IItemStack method to eg. reduce a stack, not allowing for "single use" items/tools, like fire-starters, to be created.
The damageItem could also be shrink or grow! So now you can change it.
#loader contenttweaker
import mods.contenttweaker.VanillaFactory;
import mods.contenttweaker.ActionResult;
var item = VanillaFactory.createItem("fake_flint");
item.maxStackSize = 1;
item.maxDamage = 50;
item.onItemUse = function(player, world, pos, hand, facing, blockHit) {
var firePos = pos.getOffset(facing, 1);
if (world.getBlockState(firePos).isReplaceable(world, firePos)) {
world.setBlockState(<block:minecraft:fire>, firePos));
player.getHeldItem(hand).damageItem(1, player);
return ActionResult.success();
}
return ActionResult.pass();
};
item.register();