summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2014-10-25 16:49:20 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2014-10-25 16:49:20 +0100
commit117d8c308f94f36389ee15ad8aff346d2aac2396 (patch)
treeb274f0b4c837610e8c4972cdc4b423f2d3d0e3fc
parentfd520bd520f614a7d5816b5d75cd69485e166ad6 (diff)
downloadnoctis-117d8c308f94f36389ee15ad8aff346d2aac2396.tar.bz2
Journal loading is basically working. Needs some more l10n support though. en_GB always for now
-rw-r--r--build.gradle4
-rw-r--r--src/main/java/net/flarn/noctis/Noctis.java7
-rw-r--r--src/main/java/net/flarn/noctis/init/ModItems.java3
-rw-r--r--src/main/java/net/flarn/noctis/init/Recipes.java10
-rw-r--r--src/main/java/net/flarn/noctis/item/ItemJournal.java11
-rw-r--r--src/main/java/net/flarn/noctis/journal/JournalEntry.java168
-rw-r--r--src/main/java/net/flarn/noctis/journal/JournalParser.java63
-rw-r--r--src/main/java/net/flarn/noctis/knowledge/InternalKnowledgeTree.java2
-rw-r--r--src/main/java/net/flarn/noctis/knowledge/KnowledgeItem.java6
-rw-r--r--src/main/java/net/flarn/noctis/recipes/CatalysedRecipe.java39
-rw-r--r--src/main/java/net/flarn/noctis/refs/Names.java7
-rw-r--r--src/main/resources/assets/noctis/journal/en_GB.yaml16
12 files changed, 305 insertions, 31 deletions
diff --git a/build.gradle b/build.gradle
index 2d7192c..27f401c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -34,8 +34,12 @@ repositories {
}
dependencies {
+ // Minecraft deps
compile 'codechicken:NotEnoughItems:1.7.10-1.0.2.15:dev'
compile 'codechicken:CodeChickenCore:1.7.10-1.0.2.9:dev'
+
+ // Non-Minecraft deps
+ compile 'org.yaml:snakeyaml:1.5'
}
// This task for ChickenBones came from https://github.com/AbrarSyed/SecretRoomsMod-forge
diff --git a/src/main/java/net/flarn/noctis/Noctis.java b/src/main/java/net/flarn/noctis/Noctis.java
index 6866ed7..9128504 100644
--- a/src/main/java/net/flarn/noctis/Noctis.java
+++ b/src/main/java/net/flarn/noctis/Noctis.java
@@ -6,10 +6,12 @@ import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.relauncher.Side;
import net.flarn.noctis.handler.ConfigHandler;
import net.flarn.noctis.handler.PlayerHandler;
import net.flarn.noctis.init.ModItems;
import net.flarn.noctis.init.Recipes;
+import net.flarn.noctis.journal.JournalParser;
import net.flarn.noctis.knowledge.InternalKnowledgeTree;
import net.flarn.noctis.network.PacketRegistry;
import net.flarn.noctis.proxy.IProxy;
@@ -43,8 +45,11 @@ public class Noctis {
}
@Mod.EventHandler
- public void postInit(FMLPostInitializationEvent event) {
+ public void postInit(FMLPostInitializationEvent event) throws Throwable {
// After other mods initialise
+ if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
+ JournalParser.loadJournal();
+ }
}
}
diff --git a/src/main/java/net/flarn/noctis/init/ModItems.java b/src/main/java/net/flarn/noctis/init/ModItems.java
index 0bad35e..251dc3e 100644
--- a/src/main/java/net/flarn/noctis/init/ModItems.java
+++ b/src/main/java/net/flarn/noctis/init/ModItems.java
@@ -4,16 +4,19 @@ package net.flarn.noctis.init;
import cpw.mods.fml.common.registry.GameRegistry;
import net.flarn.noctis.item.ItemCatalyst;
import net.flarn.noctis.item.ItemGlassSword;
+import net.flarn.noctis.item.ItemJournal;
import net.flarn.noctis.item.ItemNoctisBase;
import net.flarn.noctis.refs.Names;
public class ModItems {
public static final ItemNoctisBase glassSword = new ItemGlassSword();
public static final ItemCatalyst catalyst = new ItemCatalyst();
+ public static final ItemJournal journal = new ItemJournal();
public static void init() {
GameRegistry.registerItem(glassSword, Names.Items.GLASS_SWORD);
GameRegistry.registerItem(catalyst, Names.Items.CATALYST);
+ GameRegistry.registerItem(journal, Names.Items.JOURNAL);
}
}
diff --git a/src/main/java/net/flarn/noctis/init/Recipes.java b/src/main/java/net/flarn/noctis/init/Recipes.java
index 51ed35a..744405f 100644
--- a/src/main/java/net/flarn/noctis/init/Recipes.java
+++ b/src/main/java/net/flarn/noctis/init/Recipes.java
@@ -5,6 +5,7 @@ import net.flarn.noctis.handler.ConfigHandler;
import net.flarn.noctis.item.ItemCatalyst;
import net.flarn.noctis.knowledge.KnowledgeItem;
import net.flarn.noctis.recipes.CatalysedRecipe;
+import net.flarn.noctis.refs.Names;
import net.flarn.noctis.refs.Numbers;
import net.flarn.noctis.utils.CatalystType;
import net.flarn.noctis.utils.SkyAccess;
@@ -14,6 +15,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.oredict.ShapedOreRecipe;
+import net.minecraftforge.oredict.ShapelessOreRecipe;
/**
* Created by dsilvers on 19/10/14.
@@ -21,7 +23,6 @@ import net.minecraftforge.oredict.ShapedOreRecipe;
public class Recipes {
public static void init() {
- IRecipe lightCatalystRecipe;
ItemStack lightCatalystStack = ItemCatalyst.getStarterCatalyst();
ItemStack catalystMiddleItem;
if (ConfigHandler.cheapRecipes) {
@@ -30,14 +31,17 @@ public class Recipes {
catalystMiddleItem = new ItemStack(Items.ender_pearl);
}
GameRegistry.addRecipe(new ShapedOreRecipe(lightCatalystStack, "pgp", "gmg", "pgp", 'g', "blockGlassWhite", 'p', "paneGlassWhite", 'm', catalystMiddleItem));
+ GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ModItems.journal), new ItemStack(Items.book), "dyeBlack", new ItemStack(Items.feather),
+ "blockGlassWhite", "blockGlassBlack"));
+
}
public static void initCatalysedRecipes() {
/* Swiftness potion I == 8194, health potion I == 8197, these might change */
- CatalysedRecipe.newRecipe(CatalystType.LIGHT, new ItemStack(Items.potionitem, 1, 8194),
+ CatalysedRecipe.newRecipe(Names.Recipes.SPEED_POTION, CatalystType.LIGHT, new ItemStack(Items.potionitem, 1, 8194),
new ItemStack[]{new ItemStack(Items.potionitem, 1, 0), new ItemStack(Items.sugar, 1, 0)}, 10, Times.NIGHT, SkyAccess.SKY,
KnowledgeItem.findKnowledgeItem("noctis.potion.speed"), KnowledgeItem.findKnowledgeItem("noctis.potion.speed"));
- CatalysedRecipe.newRecipe(CatalystType.LIGHT, new ItemStack(Items.potionitem, 1, 8197),
+ CatalysedRecipe.newRecipe(Names.Recipes.HEALTH_POTION, CatalystType.LIGHT, new ItemStack(Items.potionitem, 1, 8197),
new ItemStack[]{new ItemStack(Items.potionitem, 1, 0), new ItemStack(Items.speckled_melon, 1, 0)}, 10, Times.NIGHT, SkyAccess.SKY,
KnowledgeItem.findKnowledgeItem("noctis.potion.health"), KnowledgeItem.findKnowledgeItem("noctis.potion.health"));
diff --git a/src/main/java/net/flarn/noctis/item/ItemJournal.java b/src/main/java/net/flarn/noctis/item/ItemJournal.java
new file mode 100644
index 0000000..8ef8b5c
--- /dev/null
+++ b/src/main/java/net/flarn/noctis/item/ItemJournal.java
@@ -0,0 +1,11 @@
+package net.flarn.noctis.item;
+
+
+import net.flarn.noctis.refs.Names;
+
+public class ItemJournal extends ItemNoctisBase {
+ public ItemJournal() {
+ super();
+ setUnlocalizedName(Names.Items.JOURNAL);
+ }
+}
diff --git a/src/main/java/net/flarn/noctis/journal/JournalEntry.java b/src/main/java/net/flarn/noctis/journal/JournalEntry.java
new file mode 100644
index 0000000..ceaabb8
--- /dev/null
+++ b/src/main/java/net/flarn/noctis/journal/JournalEntry.java
@@ -0,0 +1,168 @@
+package net.flarn.noctis.journal;
+
+
+import net.flarn.noctis.knowledge.KnowledgeItem;
+import net.flarn.noctis.recipes.CatalysedRecipe;
+import net.flarn.noctis.utils.LogHelper;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.CraftingManager;
+import net.minecraft.item.crafting.IRecipe;
+
+import java.util.*;
+
+public class JournalEntry {
+ public final KnowledgeItem knowledgeItem;
+ public final List<Page> theoryStack;
+ public final List<Page> knownStack;
+
+ public static Map<KnowledgeItem, JournalEntry> journalEntryMap = new HashMap<KnowledgeItem, JournalEntry>();
+
+ public enum PageKind {
+ UNKNOWN,
+ TEXT,
+ RECIPE,
+ CATALYSEDRECIPE;
+
+ public static PageKind fromText(String name) {
+ if (name.equals("text")) { return TEXT; }
+ if (name.equals("recipe")) { return RECIPE; }
+ if (name.equals("catalysedrecipe")) { return CATALYSEDRECIPE; }
+ return UNKNOWN;
+ }
+ }
+
+ private JournalEntry(KnowledgeItem _knowledgeItem,
+ Map pageStacks) throws JournalLoadException {
+ knowledgeItem = _knowledgeItem;
+ theoryStack = computePageStack(pageStacks.get("THEORY"));
+ knownStack = computePageStack(pageStacks.get("KNOWN"));
+ assert(knownStack != null);
+ }
+
+ public static void addJournalEntry(KnowledgeItem _knowledgeItem,
+ Map pageStacks) throws JournalLoadException {
+ if (journalEntryMap.containsKey(_knowledgeItem)){
+ throw new JournalEntryAlreadyDefinedError(_knowledgeItem.name);
+ }
+ journalEntryMap.put(_knowledgeItem, new JournalEntry(_knowledgeItem, pageStacks));
+ }
+
+ private List<Page> computePageStack(Object _pages) throws JournalLoadException {
+ List pages = (List) _pages;
+ if (pages == null) { return null; }
+ List<Page> ret = new ArrayList<Page>(pages.size());
+ for (Object o : pages) {
+ Map<String, String> pageContent = (Map<String, String>) o;
+ if (pageContent == null) { return null; }
+ String kind = pageContent.get("kind");
+ if (kind == null) { throw new MissingOrUnknownError("kind"); }
+ switch (PageKind.fromText(kind)) {
+ case UNKNOWN:
+ throw new MissingOrUnknownError("kind", kind);
+ case TEXT:
+ String body = pageContent.get("body");
+ if (body == null) { throw new MissingOrUnknownError("body"); }
+ ret.add(new PageText(body));
+ break;
+ case RECIPE:
+ String recipeGoal = pageContent.get("goal");
+ if (recipeGoal == null) { throw new MissingOrUnknownError("goal"); }
+ ret.add(new PageRecipe(recipeGoal));
+ break;
+ case CATALYSEDRECIPE:
+ String goal = pageContent.get("goal");
+ if (goal == null) { throw new MissingOrUnknownError("goal"); }
+ ret.add(new PageCatalysedRecipe(goal));
+ break;
+ }
+ }
+ return ret;
+ }
+
+ public class Page {
+ public PageKind kind;
+ public Page(PageKind _kind) {
+ kind = _kind;
+ }
+ }
+ public class PageText extends Page {
+ public String body;
+ public PageText(String _body) {
+ super(PageKind.TEXT);
+ body = _body;
+ }
+ }
+ public class PageRecipe extends Page {
+ public IRecipe recipe;
+ public PageRecipe(String goal) throws RecipeNotFound {
+ super(PageKind.RECIPE);
+ // Iterate all recipes available until we find one whose output object matches
+ // the item we're looking for... We support anything the crafting manager can do here.
+ // If we don't find one, simply assert
+ for (Object __recipe : CraftingManager.getInstance().getRecipeList()) {
+ IRecipe _recipe = (IRecipe)__recipe;
+ if (_recipe != null) {
+ ItemStack recipeGoal = _recipe.getRecipeOutput();
+ if (recipeGoal != null && goal.equals(recipeGoal.getUnlocalizedName())) {
+ // Found a recipe, it'll do
+ recipe = _recipe;
+ return;
+ }
+ }
+ }
+ // Found no recipe in this manner, so report it
+ throw new RecipeNotFound("crafting", goal);
+ }
+ }
+ public class PageCatalysedRecipe extends Page {
+ public CatalysedRecipe recipe;
+ public PageCatalysedRecipe(String goal) throws RecipeNotFound {
+ super(PageKind.CATALYSEDRECIPE);
+ // Extract the recipe named as the goal, if it's not around, throw an exception.
+ recipe = CatalysedRecipe.getRecipeByName(goal);
+ if (recipe == null) {
+ throw new RecipeNotFound("catalysed", goal);
+ }
+ }
+ }
+
+ public static abstract class JournalLoadException extends Throwable {
+ }
+
+ public static class RecipeNotFound extends JournalLoadException {
+ public final String goal;
+ public final String method;
+ public RecipeNotFound(String _method, String _goal) {
+ goal = _goal;
+ method = _method;
+ }
+ @Override
+ public String toString() {
+ return "The " + method + " recipe for `" + goal + "` was not found.";
+ }
+ }
+
+ public static class MissingOrUnknownError extends JournalLoadException {
+ public final String name;
+ public final String what;
+ public MissingOrUnknownError(String _name) {
+ name = _name;
+ what = null;
+ }
+ public MissingOrUnknownError(String _name, String _what) { name = _name; what = _what; }
+
+ @Override
+ public String toString() {
+ if (what == null) { return "Missing entry for `" + name + "`"; }
+ return "Unknown value `" + what + "` for `" + name + "` entry.";
+ }
+ }
+
+ public static class JournalEntryAlreadyDefinedError extends JournalLoadException {
+ public final String entryname;
+ public JournalEntryAlreadyDefinedError(String _entryname) { entryname = _entryname; }
+ @Override
+ public String toString() { return "Journal entry `" + entryname + "` already defined."; }
+ }
+}
diff --git a/src/main/java/net/flarn/noctis/journal/JournalParser.java b/src/main/java/net/flarn/noctis/journal/JournalParser.java
new file mode 100644
index 0000000..7030a5b
--- /dev/null
+++ b/src/main/java/net/flarn/noctis/journal/JournalParser.java
@@ -0,0 +1,63 @@
+package net.flarn.noctis.journal;
+
+
+import net.flarn.noctis.knowledge.KnowledgeItem;
+import net.flarn.noctis.utils.LogHelper;
+import net.minecraft.client.Minecraft;
+import net.minecraft.util.ResourceLocation;
+import org.yaml.snakeyaml.Loader;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.SafeConstructor;
+import org.yaml.snakeyaml.scanner.ScannerException;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+public class JournalParser {
+ public static void loadJournal() throws Throwable {
+ int size = 0;
+ Yaml loader = new Yaml(new Loader(new SafeConstructor()));
+ ResourceLocation location = new ResourceLocation("noctis:journal/en_GB.yaml");
+ JournalEntry.journalEntryMap.clear();
+ boolean succeeded = true;
+ try {
+ Iterable<Object> entries = loader.loadAll(Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream());
+ for (Object o : entries) {
+ size++;
+ Map entry = (Map) o;
+ if (entry == null) {
+ LogHelper.fatal("Entry " + size + " is not a mapping.");
+ succeeded = false;
+ continue;
+ }
+ String item = (String) entry.get("item");
+ if (item == null) { throw new JournalEntry.MissingOrUnknownError("item"); }
+ KnowledgeItem ki = KnowledgeItem.findKnowledgeItem(item);
+ if (ki == null) { throw new JournalEntry.MissingOrUnknownError("item", item); }
+ Map pageStack = (Map) entry.get("pagestack");
+ if (pageStack == null) { throw new JournalEntry.MissingOrUnknownError("pagestack"); }
+ JournalEntry.addJournalEntry(ki, pageStack);
+ }
+ LogHelper.warn("Loaded " + size + " entries of the journal!");
+ } catch (IOException ioe) {
+ LogHelper.fatal("Error loading journal");
+ throw ioe;
+ } catch (ScannerException se) {
+ LogHelper.fatal("Error scanning journal content");
+ throw se;
+ } catch (JournalEntry.JournalLoadException je) {
+ LogHelper.fatal("Error loading item " + size + " from the journal.");
+ throw je;
+ }
+ if (succeeded == false) {
+ throw new LoadFailed();
+ }
+ }
+
+ public static class LoadFailed extends Throwable {
+ public LoadFailed() {
+ super("Loading journal failed!");
+ }
+ }
+}
diff --git a/src/main/java/net/flarn/noctis/knowledge/InternalKnowledgeTree.java b/src/main/java/net/flarn/noctis/knowledge/InternalKnowledgeTree.java
index ef378eb..3736e8e 100644
--- a/src/main/java/net/flarn/noctis/knowledge/InternalKnowledgeTree.java
+++ b/src/main/java/net/flarn/noctis/knowledge/InternalKnowledgeTree.java
@@ -8,6 +8,6 @@ public class InternalKnowledgeTree {
KnowledgeItem LIGHT_CATALYST = KnowledgeItem.addKnowledgeItem("noctis.catalyst.light", true, KnowledgeVisibility.THEORY, ROOT_KNOWLEDGE);
KnowledgeItem LIGHT_BOUND_CATALYST = KnowledgeItem.addKnowledgeItem("noctis.catalyst.light.bound", true, KnowledgeVisibility.THEORY, LIGHT_CATALYST);
KnowledgeItem POTION_SPEED = KnowledgeItem.addKnowledgeItem("noctis.potion.speed", true, KnowledgeVisibility.THEORY, LIGHT_BOUND_CATALYST);
- KnowledgeItem POTION_HEALTH = KnowledgeItem.addKnowledgeItem("noctis.potion.health", true, KnowledgeVisibility.HIDDEN, LIGHT_BOUND_CATALYST);
+ KnowledgeItem POTION_HEALTH = KnowledgeItem.addKnowledgeItem("noctis.potion.health", true, KnowledgeVisibility.HIDDEN, POTION_SPEED);
}
}
diff --git a/src/main/java/net/flarn/noctis/knowledge/KnowledgeItem.java b/src/main/java/net/flarn/noctis/knowledge/KnowledgeItem.java
index ceb0ca7..4fb89da 100644
--- a/src/main/java/net/flarn/noctis/knowledge/KnowledgeItem.java
+++ b/src/main/java/net/flarn/noctis/knowledge/KnowledgeItem.java
@@ -51,9 +51,8 @@ public class KnowledgeItem {
public static KnowledgeItem addKnowledgeItem(String _name, boolean _autoGet, KnowledgeVisibility _visOnGet, KnowledgeItem... _prerequisites) {
KnowledgeItem ki = new KnowledgeItem(_name, _autoGet, _visOnGet, _prerequisites);
if (ki.findLoops(new HashSet<KnowledgeItem>())) {
- LogHelper.fatal("Loop detected adding " + ki);
+ LogHelper.error("Loop detected adding " + ki);
}
- LogHelper.warn("Knowledge item " + ki.name + " remembered");
allKnowledgeItems.put(_name, ki);
return ki;
}
@@ -65,11 +64,9 @@ public class KnowledgeItem {
public static boolean expandKnowledgeBase(KnowledgeBase b) {
boolean didExpand = false;
boolean thisExpanded = false;
- LogHelper.warn("Attempting to expand knowledgebase");
do {
thisExpanded = false;
for (KnowledgeItem ki : allKnowledgeItems.values()) {
- LogHelper.warn("Considering " + ki.name);
if (ki.autoGet == false) { continue; }
if (b.getKnowledgeVisibility(ki.name) != KnowledgeVisibility.UNKNOWN) {
continue;
@@ -81,7 +78,6 @@ public class KnowledgeItem {
break;
}
}
- LogHelper.warn("Prerequisites met? " + prereqsmet);
if (prereqsmet) {
thisExpanded = thisExpanded || b.setKnowledgeVisibility(ki.name, ki.visOnGet);
didExpand = didExpand || thisExpanded;
diff --git a/src/main/java/net/flarn/noctis/recipes/CatalysedRecipe.java b/src/main/java/net/flarn/noctis/recipes/CatalysedRecipe.java
index d27a5c9..f130058 100644
--- a/src/main/java/net/flarn/noctis/recipes/CatalysedRecipe.java
+++ b/src/main/java/net/flarn/noctis/recipes/CatalysedRecipe.java
@@ -7,10 +7,13 @@ import net.flarn.noctis.utils.*;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
public class CatalysedRecipe {
+ public final String name;
public final CatalystType catalyst;
public final ItemStack ingredients[];
public final ItemStack output;
@@ -20,16 +23,18 @@ public class CatalysedRecipe {
public final KnowledgeItem requiredKnowledge;
public final KnowledgeItem triggerKnowledge;
- private static List<CatalysedRecipe> recipes = new LinkedList();
+ private static Map<String, CatalysedRecipe> recipeMap = new HashMap<String, CatalysedRecipe>();
- private CatalysedRecipe(CatalystType _catalyst,
- ItemStack _output,
- ItemStack[] _ingredients,
- int _energy,
- Times _timeNeeded,
- SkyAccess _skyAccess,
- KnowledgeItem _requiredKnowledge,
- KnowledgeItem _triggerKnowledge) {
+ private CatalysedRecipe(String _name,
+ CatalystType _catalyst,
+ ItemStack _output,
+ ItemStack[] _ingredients,
+ int _energy,
+ Times _timeNeeded,
+ SkyAccess _skyAccess,
+ KnowledgeItem _requiredKnowledge,
+ KnowledgeItem _triggerKnowledge) {
+ name = _name;
catalyst = _catalyst;
ingredients = _ingredients;
output = _output;
@@ -40,7 +45,8 @@ public class CatalysedRecipe {
triggerKnowledge = _triggerKnowledge;
}
- public static void newRecipe(CatalystType _catalyst,
+ public static void newRecipe(String _name,
+ CatalystType _catalyst,
ItemStack _output,
ItemStack[] _ingredients,
int _energy,
@@ -48,8 +54,11 @@ public class CatalysedRecipe {
SkyAccess _skyAccess,
KnowledgeItem _requiredKnowledge,
KnowledgeItem _triggerKnowledge) {
- recipes.add(new CatalysedRecipe(_catalyst, _output, _ingredients, _energy, _timeNeeded, _skyAccess,
- _requiredKnowledge, _triggerKnowledge));
+ assert(recipeMap.containsKey(_name) == false);
+ CatalysedRecipe recipe = new CatalysedRecipe(_name, _catalyst, _output, _ingredients, _energy, _timeNeeded, _skyAccess,
+ _requiredKnowledge, _triggerKnowledge);
+ recipeMap.put(_name, recipe);
+
}
public boolean areIngredientsPresent(List entities) {
@@ -97,7 +106,7 @@ public class CatalysedRecipe {
SkyAccess skyAccessNow,
KnowledgeBase knowledgeBase) {
List<CatalysedRecipe> ret = new LinkedList();
- for (CatalysedRecipe r : recipes) {
+ for (CatalysedRecipe r : recipeMap.values()) {
if (r.energy <= energyavailable &&
now.meetsNeed(r.timeNeeded) &&
catalyst.meetsNeeds(r.catalyst) &&
@@ -110,4 +119,8 @@ public class CatalysedRecipe {
return ret;
}
+ public static CatalysedRecipe getRecipeByName(String name) {
+ return recipeMap.get(name);
+ }
+
}
diff --git a/src/main/java/net/flarn/noctis/refs/Names.java b/src/main/java/net/flarn/noctis/refs/Names.java
index 29c7790..e8b3b34 100644
--- a/src/main/java/net/flarn/noctis/refs/Names.java
+++ b/src/main/java/net/flarn/noctis/refs/Names.java
@@ -7,8 +7,15 @@ public class Names {
public static final class Items {
public static final String GLASS_SWORD = "glassSword";
public static final String CATALYST = "catalyst";
+ public static final String JOURNAL = "journal";
public static final String CATALYSTS[] = new String[] { "lightCatalyst", "darkCatalyst", "mixedCatalyst" };
public static final String CATALYST_KNOWLEDGE[] = new String[] { "noctis.catalyst.light", "noctis.catalyst.dark", "noctis.catalyst.mixed" };
public static final String CATALYST_BOUND_KNOWLEDGE[] = new String[] { "noctis.catalyst.light.bound", "noctis.catalyst.dark.bound", "noctis.catalyst.mixed.bound" };
}
+
+ public static final class Recipes {
+ public static final String NOCTIS_PREFIX = "noctis:";
+ public static final String SPEED_POTION = NOCTIS_PREFIX + "potion.speed";
+ public static final String HEALTH_POTION = NOCTIS_PREFIX + "potion.health";
+ }
}
diff --git a/src/main/resources/assets/noctis/journal/en_GB.yaml b/src/main/resources/assets/noctis/journal/en_GB.yaml
index 658b765..d975d58 100644
--- a/src/main/resources/assets/noctis/journal/en_GB.yaml
+++ b/src/main/resources/assets/noctis/journal/en_GB.yaml
@@ -42,10 +42,10 @@ pagestack:
the results of all that experimentation, I shall record here how I created this tome, that I might be
reminded always of the struggle I have been through.
# Pages can contain recipes. The recipe itself will be rendered automatically by the journal and will always
- stand on a page alone.
+ # stand on a page alone.
- kind: recipe
# The goal of a recipe is the item name which will be created. All Noctis core items start `noctis:`
- goal: noctis:journal
+ goal: "item.noctis:journal"
---
# Each entry in the journal is separated from the next by a line with three dashes on it.
@@ -74,7 +74,7 @@ pagestack:
and see what I can do with it. So that I do not forget, I have sketched the item and ideas for how I might
recreate it.
- kind: recipe
- goal: noctis:catalyst.light
+ goal: "item.noctis:lightCatalyst"
KNOWN:
- kind: text
body: |
@@ -84,7 +84,7 @@ pagestack:
to have served me well, I am recording the exact recipe here lest I lose this incredible device (or frankly
unless I feel I need more).
- kind: recipe
- goal: noctis:catalyst.light
+ goal: "item.noctis:lightCatalyst"
---
@@ -130,12 +130,12 @@ pagestack:
of these items and stepped back, raising my eyes to bask in the power of the moon.
Annoyingly, my vision seemed to end at this moment. I have no idea what I was meant to do next, if anything.
- - kind: catalyticrecipe
+ - kind: catalysedrecipe
# Since catalytic recipes can do all sorts of things, rather than naming the output item here, we name
# the recipe itself. On a theory page, such a recipe will show the types of the items, but not the amounts
# and it will show the catalyst needed but not the time of night, or whether or not the sky must be visible.
# Everything else must be hinted at in text content.
- goal: noctis:potion.speed
+ goal: "noctis:potion.speed"
KNOWN:
- kind: text
body: |
@@ -153,7 +153,7 @@ pagestack:
I have created a means to move quickly. This will surely help me evade the less savoury denizens of the night.
- kind: catalysedrecipe
- goal: noctis:potion.speed
+ goal: "noctis:potion.speed"
---
@@ -171,5 +171,5 @@ pagestack:
is a powerful restorative. This will be handy in recovering should I falter in my speed and be caught
by a Zombie or two.
- kind: catalysedrecipe
- goal: noctis:potion.health
+ goal: "noctis:potion.health"