Skip to content

LateSetCoTFunction

youyihj edited this page Jan 22, 2023 · 4 revisions

LateSetCoTFunction

@since 1.8.0

ZenUtils allows you to set CoT function lately. It means you can set it in crafttweaker scripts. With ScriptReloading, you even can reload it!

Item Block Functions

ZenUtils adds CoT Item/Block bracket handler. You can get an IItemRepresentation or IBlockRepresentation by the expression below.

<cotItem:test_item>
<cotBlock:test_block>

Note: You still be required to register items and blocks in ContentTweaker scripts.

Example

registerItems.zs

#loader contenttweaker
import mods.contenttweaker.VanillaFactory;

// register item foo
VanillaFactory.createItem("foo").register();

setFunction.zs

// the loader setting allows you to reload the script
#loader crafttweaker reloadable
import mods.contenttweaker.ActionResult;

// get the CoT item and set function
<cotItem:foo>.onItemUse = function(player, world, pos, hand, facing, blockHit) {
    player.sendMessage("burrrrrrrrr");
    return ActionResult.success();
}

Tile Entity Functions

For ZenUtils Tile Entity Functions, You can call VanillaFactory.putTileEntityTickFunction(int id, ITileEntityTick tileEntityTick). The function also is reloadable.

Clone this wiki locally