Flywheel/src/main/java/com/jozufozu/flywheel/backend/ResourceUtil.java
JozsefA 9352ef9ede Json program specs, new extension/gamestate system.
- Program specs are now loaded from json instead of being defined in code and registered manually.
 - Within the json spec, a program can define a list of states.
 - A state consists of:
   - A "when" clause.
   - A list of strings to be #defined.
   - A list of extensions to apply at program link time.
 - Each frame, the first state whose "when" clause returns true will be used.
 - A when clause consists of:
  - A state provider defined by a resource location.
  - A value to match.
 - When the value returned by the provider matches the value defined in the when clause, the when clause is considered to be 'true'.
 - There is syntactic sugar for when a provider returns a boolean value.
 - This system is in its infancy, and there is plenty of room for improvement.
2021-05-22 17:45:01 -07:00

19 lines
710 B
Java

package com.jozufozu.flywheel.backend;
import net.minecraft.util.ResourceLocation;
public class ResourceUtil {
public static ResourceLocation subPath(ResourceLocation root, String subPath) {
return new ResourceLocation(root.getNamespace(), root.getPath() + subPath);
}
public static ResourceLocation removePrefixUnchecked(ResourceLocation full, String root) {
return new ResourceLocation(full.getNamespace(), full.getPath().substring(root.length()));
}
public static ResourceLocation trim(ResourceLocation loc, String prefix, String suffix) {
String path = loc.getPath();
return new ResourceLocation(loc.getNamespace(), path.substring(prefix.length(), path.length() - suffix.length()));
}
}