Search in sources :

Example 1 with Event

use of net.minecraftforge.common.animation.Event in project MinecraftForge by MinecraftForge.

the class AnimationStateMachine method apply.

public Pair<IModelState, Iterable<Event>> apply(float time) {
    if (lastPollTime == Float.NEGATIVE_INFINITY) {
        lastPollTime = time;
    }
    Pair<IModelState, Iterable<Event>> pair = clipCache.getUnchecked(Triple.of(currentState, lastPollTime, time));
    lastPollTime = time;
    boolean shouldFilter = false;
    if (shouldHandleSpecialEvents) {
        for (Event event : ImmutableList.copyOf(pair.getRight()).reverse()) {
            if (event.event().startsWith("!")) {
                shouldFilter = true;
                if (event.event().startsWith("!transition:")) {
                    String newState = event.event().substring("!transition:".length());
                    transition(newState);
                } else {
                    System.out.println("Unknown special event \"" + event.event() + "\", ignoring");
                }
            }
        }
    }
    if (!shouldFilter) {
        return pair;
    }
    return Pair.of(pair.getLeft(), Iterables.filter(pair.getRight(), new Predicate<Event>() {

        public boolean apply(Event event) {
            return !event.event().startsWith("!");
        }
    }));
}
Also used : IModelState(net.minecraftforge.common.model.IModelState) Event(net.minecraftforge.common.animation.Event) Predicate(com.google.common.base.Predicate)

Example 2 with Event

use of net.minecraftforge.common.animation.Event in project BloodMagic by WayofTime.

the class ClientProxy method preInit.

@Override
public void preInit() {
    super.preInit();
    OBJLoader.INSTANCE.addDomain(BloodMagic.MODID);
    ClientRegistry.bindTileEntitySpecialRenderer(TileInversionPillar.class, new AnimationTESR<TileInversionPillar>() {

        @Override
        public void handleEvents(TileInversionPillar chest, float time, Iterable<Event> pastEvents) {
            chest.handleEvents(time, pastEvents);
        }
    });
    ClientRegistry.bindTileEntitySpecialRenderer(TileAlchemyArray.class, new RenderAlchemyArray());
    ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderAltar());
    ClientRegistry.bindTileEntitySpecialRenderer(TileRoutingNode.class, new RenderItemRoutingNode());
    ClientRegistry.bindTileEntitySpecialRenderer(TileDemonCrucible.class, new RenderDemonCrucible());
    ClientRegistry.bindTileEntitySpecialRenderer(TileMimic.class, new RenderMimic());
    ClientRegistry.bindTileEntitySpecialRenderer(TileBloodTank.class, new RenderBloodTank());
    // Initialize key-binds during startup so they load correctly
    for (KeyBindings key : KeyBindings.values()) key.getKey();
}
Also used : KeyBindings(WayofTime.bloodmagic.client.key.KeyBindings) Event(net.minecraftforge.common.animation.Event)

Aggregations

Event (net.minecraftforge.common.animation.Event)2 KeyBindings (WayofTime.bloodmagic.client.key.KeyBindings)1 Predicate (com.google.common.base.Predicate)1 IModelState (net.minecraftforge.common.model.IModelState)1