ContentTweaker

ContentTweaker

27M Downloads

Add blockpos parameter to IItemRightClick

Fiaegel opened this issue ยท 2 comments

commented

Functions that require the player to use an item on a block are not possible in the current version (4.1.0)

commented

Won't be changing the IItemRightClick function. However! I will be adding a different function (onUse) that is called specifically when a User clicked on a block.

commented

This should do most of what you need?

#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();