2021-06-07 00:46:16 +02:00
|
|
|
package com.jozufozu.flywheel.backend;
|
2021-05-23 02:45:01 +02:00
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2021-05-31 02:05:41 +02:00
|
|
|
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
2021-05-23 02:45:01 +02:00
|
|
|
|
2021-09-15 08:45:29 +02:00
|
|
|
import net.minecraft.resources.ResourceLocation;
|
2021-05-23 02:45:01 +02:00
|
|
|
|
2021-12-03 02:40:23 +01:00
|
|
|
public class GameStateRegistry {
|
2021-05-23 02:45:01 +02:00
|
|
|
|
|
|
|
private static final Map<ResourceLocation, IGameStateProvider> registeredStateProviders = new HashMap<>();
|
|
|
|
|
2021-06-07 00:46:16 +02:00
|
|
|
static void clear() {
|
|
|
|
registeredStateProviders.clear();
|
2021-05-23 02:45:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static IGameStateProvider getStateProvider(ResourceLocation location) {
|
|
|
|
IGameStateProvider out = registeredStateProviders.get(location);
|
|
|
|
|
|
|
|
if (out == null) {
|
|
|
|
throw new IllegalArgumentException("State provider '" + location + "' does not exist.");
|
|
|
|
}
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void register(IGameStateProvider context) {
|
|
|
|
if (registeredStateProviders.containsKey(context.getID())) {
|
|
|
|
throw new IllegalStateException("Duplicate game state provider: " + context.getID());
|
|
|
|
}
|
|
|
|
|
|
|
|
registeredStateProviders.put(context.getID(), context);
|
|
|
|
}
|
|
|
|
}
|