Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Fabric 1.19.2] Can't get single play GeckoLib animations to work properly

Featured Replies

Posted

I'm trying to use Geckolib to have a block animation play when the block is right clicked, however it isn't working properly. When I right click the block the animation will play once, and then any subsequent times I right click, nothing happens.

Here's my Block class:

public class MagicChurnerBlock extends BlockWithEntity {

    protected MagicChurnerBlock(Settings settings) {
        super(settings);
    }

    @Nullable
    @Override
    public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
        return new MagicChurner(pos, state);
    }

    @Nullable
    @Override
    public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
        return checkType(type, DiabolismEntities.MAGIC_CHURNER_BLOCKENTITY, MagicChurner::ticker);
    }

    @Override
    public BlockRenderType getRenderType(BlockState state) {
        return BlockRenderType.ENTITYBLOCK_ANIMATED;
    }

    @Override
    public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
        MagicChurner magicChurner = (MagicChurner) world.getBlockEntity(pos);
        if(magicChurner != null && world.isClient){
            magicChurner.turn();
        }
        return ActionResult.SUCCESS;
    }
}

And my Block Entity Class:

public class MagicChurner extends AbstractFluidContainer implements IAnimatable {

    private AnimationFactory factory = new InstancedAnimationFactory(this);
    private boolean hasBeenTurned =false;

    public MagicChurner(BlockPos pos, BlockState state) {
        super(DiabolismEntities.MAGIC_CHURNER_BLOCKENTITY, pos, state, 1000);
    }

    @Override
    public void registerControllers(AnimationData animationData) {
        animationData.addAnimationController(new AnimationController<MagicChurner>(this, "controller", 0, this::predicate));

    }

    private <E extends IAnimatable>PlayState predicate(AnimationEvent<E> event){
        if(hasBeenTurned) {
            event.getController().setAnimation(new AnimationBuilder().addAnimation("magic_churner_turn", (ILoopType) ILoopType.EDefaultLoopTypes.PLAY_ONCE));
            hasBeenTurned = false;
        }
       return PlayState.CONTINUE;
    }

    @Override
    public AnimationFactory getFactory() {
        return this.factory;
    }

    public static void ticker(World world, BlockPos pos, BlockState state, MagicChurner be) {
        be.tick(world, pos, state);
    }

    private void tick(World world, BlockPos pos, BlockState state) {
    }

    public void turn(){
        this.hasBeenTurned = true;
    }

Edited by Jipthechip

  • Jipthechip changed the title to [Fabric 1.19.2] Can't get single play GeckoLib animations to work properly

That code is not for Forge 1.19.2

And questions about geckolib should be asked to them.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Guest
This topic is now closed to further replies.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.