Remove json, implement mutual exclusives, adjustments & fix bugs
This commit is contained in:
@@ -13,6 +13,7 @@ import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -34,38 +35,28 @@ public class AbilityNodeLoader extends SimpleJsonResourceReloadListener {
|
||||
|
||||
@Override
|
||||
protected void apply(Map<ResourceLocation, JsonElement> jsons,
|
||||
ResourceManager resourceManager,
|
||||
ProfilerFiller profiler) {
|
||||
|
||||
@NotNull ResourceManager resourceManager,
|
||||
@NotNull ProfilerFiller profiler) {
|
||||
SkillEngine.LOGGER.info("Loading ability nodes...");
|
||||
|
||||
AbilityNodeRegistry.clear();
|
||||
|
||||
jsons.forEach((id, json) -> {
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
|
||||
Component title = Component.literal(obj.get("title").getAsString());
|
||||
Component description = Component.literal(obj.get("description").getAsString());
|
||||
JsonObject pos = obj.getAsJsonObject("position");
|
||||
float x = pos.get("x").getAsFloat();
|
||||
float y = pos.get("y").getAsFloat();
|
||||
|
||||
List<ResourceLocation> links = new ArrayList<>();
|
||||
obj.getAsJsonArray("links").forEach(e ->
|
||||
links.add(new ResourceLocation(e.getAsString())));
|
||||
|
||||
List<ResourceLocation> tags = new ArrayList<>();
|
||||
obj.getAsJsonArray("tags").forEach(e ->
|
||||
tags.add(new ResourceLocation(e.getAsString())));
|
||||
|
||||
ResourceLocation icon = new ResourceLocation(obj.get("icon").getAsString());
|
||||
|
||||
int cooldown = obj.has("cooldown") ? obj.get("cooldown").getAsInt() : 0;
|
||||
|
||||
AbilityNode node = new AbilityNode(id, title, description, x, y, links, tags, icon, cooldown);
|
||||
AbilityNodeRegistry.put(node);
|
||||
});
|
||||
|
||||
SkillEngine.LOGGER.info("Loaded {} active ability nodes", AbilityNodeRegistry.all().size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,21 +7,16 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AbilityNodeRegistry {
|
||||
|
||||
private static final Map<ResourceLocation, AbilityNode> ABILITIES = new LinkedHashMap<>();
|
||||
|
||||
public static void clear() {
|
||||
ABILITIES.clear();
|
||||
}
|
||||
|
||||
public static void put(AbilityNode node) {
|
||||
ABILITIES.put(node.getId(), node);
|
||||
}
|
||||
|
||||
public static AbilityNode get(ResourceLocation id) {
|
||||
return ABILITIES.get(id);
|
||||
}
|
||||
|
||||
public static Collection<AbilityNode> all() {
|
||||
return ABILITIES.values();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -32,8 +33,8 @@ public class SkillNodeLoader extends SimpleJsonResourceReloadListener {
|
||||
|
||||
@Override
|
||||
protected void apply(Map<ResourceLocation, JsonElement> jsons,
|
||||
ResourceManager resourceManager,
|
||||
ProfilerFiller profiler) {
|
||||
@NotNull ResourceManager resourceManager,
|
||||
@NotNull ProfilerFiller profiler) {
|
||||
SkillEngine.LOGGER.info("Loading skill nodes...");
|
||||
SkillNodeRegistry.clear();
|
||||
jsons.forEach((id, element) -> {
|
||||
|
||||
Reference in New Issue
Block a user