Search in sources :

Example 1 with AnimationBuilder

use of software.bernie.geckolib3.core.builder.AnimationBuilder in project MCDoom by AzureDoom.

the class SentinelDoomArmor method predicate.

private <P extends IAnimatable> PlayState predicate(AnimationEvent<P> event) {
    LivingEntity livingEntity = event.getExtraDataOfType(LivingEntity.class).get(0);
    if (livingEntity instanceof ArmorStandEntity) {
        return PlayState.STOP;
    }
    event.getController().setAnimation(new AnimationBuilder().addAnimation("idle", true));
    return PlayState.CONTINUE;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) AnimationBuilder(software.bernie.geckolib3.core.builder.AnimationBuilder) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity)

Example 2 with AnimationBuilder

use of software.bernie.geckolib3.core.builder.AnimationBuilder in project MCDoom by AzureDoom.

the class ZombieDoomArmor method predicate.

private <P extends IAnimatable> PlayState predicate(AnimationEvent<P> event) {
    LivingEntity livingEntity = event.getExtraDataOfType(LivingEntity.class).get(0);
    if (livingEntity instanceof ArmorStandEntity) {
        return PlayState.STOP;
    }
    event.getController().setAnimation(new AnimationBuilder().addAnimation("idle", true));
    return PlayState.CONTINUE;
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) AnimationBuilder(software.bernie.geckolib3.core.builder.AnimationBuilder) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity)

Example 3 with AnimationBuilder

use of software.bernie.geckolib3.core.builder.AnimationBuilder 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 4 with AnimationBuilder

use of software.bernie.geckolib3.core.builder.AnimationBuilder in project geckolib by bernie-g.

the class PotatoArmorItem method predicate.

// Predicate runs every frame
@SuppressWarnings("unused")
private <P extends IAnimatable> PlayState predicate(AnimationEvent<P> event) {
    // This is all the extradata this event carries. The livingentity is the entity
    // that's wearing the armor. The itemstack and equipmentslottype are self
    // explanatory.
    List<EquipmentSlot> slotData = event.getExtraDataOfType(EquipmentSlot.class);
    List<ItemStack> stackData = event.getExtraDataOfType(ItemStack.class);
    LivingEntity livingEntity = event.getExtraDataOfType(LivingEntity.class).get(0);
    // Always loop the animation but later on in this method we'll decide whether or
    // not to actually play it
    event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.potato_armor.new", true));
    // If the living entity is an armorstand just play the animation nonstop
    if (livingEntity instanceof ArmorStand) {
        return PlayState.CONTINUE;
    } else // full set of armor
    if (livingEntity instanceof Player) {
        Player player = (Player) livingEntity;
        // Get all the equipment, aka the armor, currently held item, and offhand item
        List<Item> equipmentList = new ArrayList<>();
        player.getAllSlots().forEach((x) -> equipmentList.add(x.getItem()));
        // elements 2 to 6 are the armor so we take the sublist. Armorlist now only
        // contains the 4 armor slots
        List<Item> armorList = equipmentList.subList(2, 6);
        // Make sure the player is wearing all the armor. If they are, continue playing
        // the animation, otherwise stop
        boolean isWearingAll = armorList.containsAll(Arrays.asList(ItemRegistry.POTATO_BOOTS.get(), ItemRegistry.POTATO_LEGGINGS.get(), ItemRegistry.POTATO_CHEST.get(), ItemRegistry.POTATO_HEAD.get()));
        return isWearingAll ? PlayState.CONTINUE : PlayState.STOP;
    }
    return PlayState.STOP;
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) AnimationBuilder(software.bernie.geckolib3.core.builder.AnimationBuilder) Arrays(java.util.Arrays) LivingEntity(net.minecraft.world.entity.LivingEntity) GeckoLibMod(software.bernie.example.GeckoLibMod) IAnimatable(software.bernie.geckolib3.core.IAnimatable) AnimationController(software.bernie.geckolib3.core.controller.AnimationController) Item(net.minecraft.world.item.Item) GeoArmorItem(software.bernie.geckolib3.item.GeoArmorItem) AnimationFactory(software.bernie.geckolib3.core.manager.AnimationFactory) ArrayList(java.util.ArrayList) Player(net.minecraft.world.entity.player.Player) List(java.util.List) ArmorMaterial(net.minecraft.world.item.ArmorMaterial) EquipmentSlot(net.minecraft.world.entity.EquipmentSlot) AnimationData(software.bernie.geckolib3.core.manager.AnimationData) AnimationEvent(software.bernie.geckolib3.core.event.predicate.AnimationEvent) ArmorStand(net.minecraft.world.entity.decoration.ArmorStand) ItemStack(net.minecraft.world.item.ItemStack) ItemRegistry(software.bernie.example.registry.ItemRegistry) PlayState(software.bernie.geckolib3.core.PlayState) Player(net.minecraft.world.entity.player.Player) ArmorStand(net.minecraft.world.entity.decoration.ArmorStand) EquipmentSlot(net.minecraft.world.entity.EquipmentSlot) ArrayList(java.util.ArrayList) List(java.util.List) AnimationBuilder(software.bernie.geckolib3.core.builder.AnimationBuilder) ItemStack(net.minecraft.world.item.ItemStack)

Example 5 with AnimationBuilder

use of software.bernie.geckolib3.core.builder.AnimationBuilder in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityCQREnderCalamity method predicateArmRightMiddle.

private <E extends IAnimatable> PlayState predicateArmRightMiddle(AnimationEvent<E> event) {
    // Death animation
    if (this.dead || this.getHealth() < 0.01 || !this.isAlive()) {
        return PlayState.STOP;
    }
    if (event.getController().getCurrentAnimation() == null) {
        event.getController().setAnimation(new AnimationBuilder().addAnimation(ANIM_NAME_ARM_RM_IDLE, true));
    }
    if (this.updateIndicator_Hand_RM) {
        event.getController().clearAnimationCache();
        this.updateIndicator_Hand_RM = false;
        event.getController().setAnimation(new AnimationBuilder().addAnimation(ANIM_NAME_ARM_RM_THROW).addAnimation(ANIM_NAME_ARM_RM_IDLE, true));
    }
    return PlayState.CONTINUE;
}
Also used : AnimationBuilder(software.bernie.geckolib3.core.builder.AnimationBuilder)

Aggregations

AnimationBuilder (software.bernie.geckolib3.core.builder.AnimationBuilder)17 LivingEntity (net.minecraft.entity.LivingEntity)4 ArmorStandEntity (net.minecraft.entity.decoration.ArmorStandEntity)4 AnimationController (software.bernie.geckolib3.core.controller.AnimationController)3 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)1 LocalPlayer (net.minecraft.client.player.LocalPlayer)1 TextComponent (net.minecraft.network.chat.TextComponent)1 EquipmentSlot (net.minecraft.world.entity.EquipmentSlot)1 LivingEntity (net.minecraft.world.entity.LivingEntity)1 ArmorStand (net.minecraft.world.entity.decoration.ArmorStand)1 Player (net.minecraft.world.entity.player.Player)1 ArmorMaterial (net.minecraft.world.item.ArmorMaterial)1 Item (net.minecraft.world.item.Item)1 ItemStack (net.minecraft.world.item.ItemStack)1 GeckoLibMod (software.bernie.example.GeckoLibMod)1 ItemRegistry (software.bernie.example.registry.ItemRegistry)1 IAnimatable (software.bernie.geckolib3.core.IAnimatable)1