Search in sources :

Example 1 with AnimationController

use of software.bernie.geckolib3.core.controller.AnimationController in project ProbablyChests by ReillyGregorio.

the class PCChestBlockEntity method registerControllers.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void registerControllers(AnimationData data) {
    AnimationController controller = new AnimationController(this, CONTROLLER_NAME, 0, animationEvent -> {
        switch(getChestState()) {
            case CLOSE:
                if (animationEvent.getController().getAnimationState() == AnimationState.Stopped) {
                    setChestState(PCChestState.CLOSED);
                    animationEvent.getController().setAnimation(CLOSED);
                    break;
                }
                if (animationEvent.getController().getCurrentAnimation() != null && !animationEvent.getController().getCurrentAnimation().animationName.equals(CLOSED.getRawAnimationList().get(0).animationName)) {
                    animationEvent.getController().setAnimation(CLOSE);
                }
                break;
            case OPEN:
                if (animationEvent.getController().getAnimationState() == AnimationState.Stopped) {
                    setChestState(PCChestState.OPENED);
                    animationEvent.getController().setAnimation(OPENED);
                    break;
                }
                if (animationEvent.getController().getCurrentAnimation() != null && !animationEvent.getController().getCurrentAnimation().animationName.equals(OPENED.getRawAnimationList().get(0).animationName)) {
                    animationEvent.getController().setAnimation(OPEN);
                }
                break;
            default:
                break;
        }
        return PlayState.CONTINUE;
    });
    data.addAnimationController(controller);
}
Also used : AnimationController(software.bernie.geckolib3.core.controller.AnimationController)

Example 2 with AnimationController

use of software.bernie.geckolib3.core.controller.AnimationController in project bioplethora by AquexTheSeal.

the class AlphemKingEntity method registerControllers.

@Override
public void registerControllers(AnimationData data) {
    AnimationController controller = new AnimationController<>(this, "alphem_king_controller", 0, this::predicate);
    data.addAnimationController(controller);
    controller.registerParticleListener(this::particleListener);
}
Also used : AnimationController(software.bernie.geckolib3.core.controller.AnimationController)

Example 3 with AnimationController

use of software.bernie.geckolib3.core.controller.AnimationController in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityCQREnderCalamity method registerControllers.

@SuppressWarnings("unchecked")
@Override
public void registerControllers(AnimationData data) {
    data.addAnimationController(new AnimationController<>(this, "controller", 10, this::predicate));
    // Spin hands controller
    // data.addAnimationController(new AnimationController<EntityCQREnderCalamity>(this, "controller_spin_hands", 10,
    // this::predicateSpinHands));
    // Arms
    @SuppressWarnings("rawtypes") AnimationController[] handControllers = new AnimationController[] { new AnimationController<>(this, "controller_arm_ru", 5, this::predicateArmRightUpper), new AnimationController<>(this, "controller_arm_rm", 5, this::predicateArmRightMiddle), new AnimationController<>(this, "controller_arm_rl", 5, this::predicateArmRightLower), new AnimationController<>(this, "controller_arm_lu", 5, this::predicateArmLeftUpper), new AnimationController<>(this, "controller_arm_lm", 5, this::predicateArmLeftMiddle), new AnimationController<>(this, "controller_arm_ll", 5, this::predicateArmLeftLower) };
    for (@SuppressWarnings("rawtypes") AnimationController ac : handControllers) {
        ac.registerSoundListener(this::soundListenerArms);
        data.addAnimationController(ac);
    }
}
Also used : AnimationController(software.bernie.geckolib3.core.controller.AnimationController)

Example 4 with AnimationController

use of software.bernie.geckolib3.core.controller.AnimationController in project geckolib by bernie-g.

the class JackInTheBoxItem method onAnimationSync.

@SuppressWarnings({ "rawtypes", "resource" })
@Override
public void onAnimationSync(int id, int state) {
    if (state == ANIM_OPEN) {
        // Always use GeckoLibUtil to get AnimationControllers when you don't have
        // access to an AnimationEvent
        final AnimationController controller = GeckoLibUtil.getControllerForID(this.factory, id, CONTROLLER_NAME);
        if (controller.getAnimationState() == AnimationState.Stopped) {
            final LocalPlayer player = Minecraft.getInstance().player;
            if (player != null) {
                player.displayClientMessage(new TextComponent("Opening the jack in the box!"), true);
            }
            // If you don't do this, the popup animation will only play once because the
            // animation will be cached.
            controller.markNeedsReload();
            // Set the animation to open the JackInTheBoxItem which will start playing music
            // and
            // eventually do the actual animation. Also sets it to not loop
            controller.setAnimation(new AnimationBuilder().addAnimation("Soaryn_chest_popup", false));
        }
    }
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) AnimationController(software.bernie.geckolib3.core.controller.AnimationController) LocalPlayer(net.minecraft.client.player.LocalPlayer) AnimationBuilder(software.bernie.geckolib3.core.builder.AnimationBuilder)

Example 5 with AnimationController

use of software.bernie.geckolib3.core.controller.AnimationController in project geckolib by bernie-g.

the class JackInTheBoxItem method registerControllers.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void registerControllers(AnimationData data) {
    AnimationController controller = new AnimationController(this, CONTROLLER_NAME, 20, this::predicate);
    // Registering a sound listener just makes it so when any sound keyframe is hit
    // the method will be called.
    // To register a particle listener or custom event listener you do the exact
    // same thing, just with registerParticleListener and
    // registerCustomInstructionListener, respectively.
    controller.registerSoundListener(this::soundListener);
    data.addAnimationController(controller);
}
Also used : AnimationController(software.bernie.geckolib3.core.controller.AnimationController)

Aggregations

AnimationController (software.bernie.geckolib3.core.controller.AnimationController)6 AnimationBuilder (software.bernie.geckolib3.core.builder.AnimationBuilder)3 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)1 LocalPlayer (net.minecraft.client.player.LocalPlayer)1 TextComponent (net.minecraft.network.chat.TextComponent)1