net.minecraftforge.common.animation.ITimeValue Java Examples

The following examples show how to use net.minecraftforge.common.animation.ITimeValue. 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
/**
 * Load a new instance of HarvesterAnimationStateMachine at specified location,
 * with specified custom parameters.
 */
@SideOnly(Side.CLIENT)
public static HarvesterAnimationStateMachine load(IResourceManager manager, ResourceLocation location,
        ImmutableMap<String, ITimeValue> customParameters) {
    try (IResource resource = manager.getResource(location)) {
        ClipResolver clipResolver = new ClipResolver();
        ParameterResolver parameterResolver = new ParameterResolver(customParameters);
        Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(clipResolver);
        TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(parameterResolver);
        HarvesterAnimationStateMachine asm = asmGson.fromJson(
                new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8),
                HarvesterAnimationStateMachine.class);
        clipResolver.asm = asm;
        parameterResolver.asm = asm;
        asm.initialize();

        return asm;
    } catch (IOException | JsonParseException e) {
        FMLLog.log.error("Exception loading Animation State Machine {}, skipping", location, e);
        return missing;
    } finally {
        Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(null);
        TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(null);
    }
}
 
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 ITimeValue apply(String name) {
    if (asm.parameters.containsKey(name)) {
        return asm.parameters.get(name);
    }
    return customParameters.get(name);
}
 
Example #5
Source File: AnimationHelper.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
public static HarvesterAnimationStateMachine loadHarvesterASM(ResourceLocation location, ImmutableMap<String, ITimeValue> customParameters) {
    IResourceManager manager = Minecraft.getMinecraft().getResourceManager();
    return HarvesterAnimationStateMachine.load(manager, location, customParameters);
}
 
Example #6
Source File: HarvesterAnimationStateMachine.java    From EmergingTechnology with MIT License 4 votes vote down vote up
public ParameterResolver(ImmutableMap<String, ITimeValue> customParameters) {
    this.customParameters = customParameters;
}
 
Example #7
Source File: ClientProxy.java    From YouTubeModdingTutorial with MIT License 4 votes vote down vote up
@Override
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters) {
    return ModelLoaderRegistry.loadASM(location, parameters);
}
 
Example #8
Source File: CommonProxy.java    From YouTubeModdingTutorial with MIT License 4 votes vote down vote up
@Nullable
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters) {
    return null;
}
 
Example #9
Source File: OpenClientProxy.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public IAnimationStateMachine loadAsm(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters) {
	return ModelLoaderRegistry.loadASM(location, parameters);
}
 
Example #10
Source File: OpenServerProxy.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public IAnimationStateMachine loadAsm(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters) {
	return null;
}
 
Example #11
Source File: IOpenModsProxy.java    From OpenModsLib with MIT License votes vote down vote up
public IAnimationStateMachine loadAsm(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters);