net.minecraftforge.common.model.animation.IClip Java Examples

The following examples show how to use net.minecraftforge.common.model.animation.IClip. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HarvesterAnimationStateMachine.java    From EmergingTechnology with MIT License 6 votes vote down vote up
/**
 * post-loading initialization hook.
 */
void initialize() {
    if (parameters == null) {
        throw new JsonParseException("Animation State Machine should contain \"parameters\" key.");
    }
    if (clips == null) {
        throw new JsonParseException("Animation State Machine should contain \"clips\" key.");
    }
    if (states == null) {
        throw new JsonParseException("Animation State Machine should contain \"states\" key.");
    }
    if (transitions == null) {
        throw new JsonParseException("Animation State Machine should contain \"transitions\" key.");
    }
    shouldHandleSpecialEvents = true;
    lastPollTime = Float.NEGATIVE_INFINITY;
    // setting the starting state
    IClip state = clips.get(startState);
    if (!clips.containsKey(startState) || !states.contains(startState)) {
        throw new IllegalStateException("unknown state: " + startState);
    }
    currentStateName = startState;
    currentState = state;
}
 
Example #2
Source File: HarvesterAnimationStateMachine.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Deprecated
public HarvesterAnimationStateMachine(ImmutableMap<String, ITimeValue> parameters,
        ImmutableMap<String, IClip> clips, ImmutableList<String> states, ImmutableMap<String, String> transitions,
        String startState) {
    this(parameters, clips, states, ImmutableMultimap.copyOf(
            Multimaps.newSetMultimap(Maps.transformValues(transitions, ImmutableSet::of), Sets::newHashSet)),
            startState);
}
 
Example #3
Source File: HarvesterAnimationStateMachine.java    From EmergingTechnology with MIT License 5 votes vote down vote up
public HarvesterAnimationStateMachine(ImmutableMap<String, ITimeValue> parameters,
        ImmutableMap<String, IClip> clips, ImmutableList<String> states,
        ImmutableMultimap<String, String> transitions, String startState) {
    this.parameters = parameters;
    this.clips = clips;
    this.states = states;
    this.transitions = transitions;
    this.startState = startState;
}
 
Example #4
Source File: HarvesterAnimationStateMachine.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Override
public void transition(String newState) {

    IClip nc = clips.get(newState);

    if (!clips.containsKey(newState) || !states.contains(newState)) {
        throw new IllegalStateException("unknown state: " + newState);
    }
    if (!transitions.containsEntry(currentStateName, newState)) {
        throw new IllegalArgumentException("no transition from current clip \"" + currentStateName
                + "\" to the clip \"" + newState + "\" found.");
    }
    currentStateName = newState;
    currentState = nc;
}
 
Example #5
Source File: VanillaModelWrapper.java    From VanillaFix with MIT License 5 votes vote down vote up
@Override
public Optional<? extends IClip> getClip(String name) {
    if (animation.getClips().containsKey(name)) {
        return Optional.ofNullable(animation.getClips().get(name));
    }

    return Optional.empty();
}
 
Example #6
Source File: EvaluatorFactory.java    From OpenModsLib with MIT License 5 votes vote down vote up
private static ITransformExecutor createForClip(final IClip clip, final NumericExpr param) {
	return (initial, joint, args) -> {
		final float paramValue = param.evaluate(args);
		final TRSRTransformation clipTransform = clip.apply(joint).apply(paramValue);
		return initial.compose(clipTransform);
	};
}
 
Example #7
Source File: HarvesterAnimationStateMachine.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Override
public IClip apply(String name) {
    return asm.clips.get(name);
}
 
Example #8
Source File: EvaluatorFactory.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public ITransformExecutor bind(IClipProvider provider) {
	final Optional<? extends IClip> clip = provider.get(clipName);
	Preconditions.checkState(clip.isPresent(), "Can't find clip '%s'", clipName);
	return createForClip(clip.get(), param);
}
 
Example #9
Source File: EvalModelTest.java    From OpenModsLib with MIT License 4 votes vote down vote up
public TestClipProvider put(String key, IClip clip) {
	clips.put(key, clip);
	return this;
}
 
Example #10
Source File: EvalModelTest.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public Optional<? extends IClip> get(String name) {
	return Optional.ofNullable(clips.get(name));
}
 
Example #11
Source File: EvalModelTest.java    From OpenModsLib with MIT License 4 votes vote down vote up
private static TestClipProvider clips(String key, IClip clip) {
	return new TestClipProvider().put(key, clip);
}
 
Example #12
Source File: EvaluatorFactory.java    From OpenModsLib with MIT License votes vote down vote up
public Optional<? extends IClip> get(String name);