ContentTweaker icon indicating copy to clipboard operation
ContentTweaker copied to clipboard

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

Open friendlyhj opened this issue 5 years ago • 6 comments

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.

friendlyhj avatar Jan 01 '20 04:01 friendlyhj

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.

sysyss avatar Feb 01 '21 07:02 sysyss

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

friendlyhj avatar Feb 01 '21 08:02 friendlyhj

This appears to apply to onRandomTick as well.

Hate9 avatar Jun 21 '21 01:06 Hate9

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

democat3457 avatar Jun 21 '21 03:06 democat3457

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.

Hate9 avatar Jun 22 '21 21:06 Hate9

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?

Cephelo avatar May 04 '22 02:05 Cephelo