ContentTweaker

ContentTweaker

27M Downloads

onUpdateTick function doesn't work unless the block has gravity.

friendlyhj opened this issue ยท 6 comments

commented

My script

val colliderOne as Block = VanillaFactory.createBlock("collider_lv1", <blockmaterial:iron>);
colliderOne.setToolClass("pickaxe");
colliderOne.setToolLevel(0);
// colliderOne.gravity = true;
colliderOne.onUpdateTick = function(world, blockPos, blockState) {
    print("Update!");
};
colliderOne.register();

I gave the block a block update, but nothing happened in crafttweaker.log. But if I set gravity property true, it will work.

commented

Can confirm onUpdateTick is still broken, unless the block has gravity as stated before.
[1.12.2]

Edit: It looks like this is deliberate, and not a bug:
https://github.com/CraftTweaker/ContentTweaker/blob/develop/1.12/src/main/java/com/teamacronymcoders/contenttweaker/modules/vanilla/blocks/BlockContent.java#L193

In other words, onUpdateTick deliberately does nothing if the block has no gravity.
The question is, why was this done?

commented

I know it. I placed a block near the block to give block change.

commented

by that i konw, block update call when
-its change(mine it, open it(like chest) )
-its neer is change(mine side block, piston is neer push or pull)
-its other update fuct(redstone, has random tick(work like plant), gravity fall check. )

not call with every tick update.

commented

This appears to apply to onRandomTick as well.

commented

onRandomTick works fine, according to my usage: https://github.com/Rebirth-of-the-Night/Rebirth-Of-The-Night/blob/master/src/common/scripts/contentweaker/scaffolding.zs this block breaks on a random interval without needing gravity

commented

Oh huh. Yeah, it seems to be working now.

To anyone reading this thread later, I'm referring to onRandomTick. onUpdateTick still doesn't work correctly.