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;
}
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;
}
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));
}
}
}
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;
}
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;
}
Aggregations