diff options
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java | 17 | ||||
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java | 16 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java index ef030367..5a228dc4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java @@ -29,10 +29,14 @@ import com.google.gson.JsonParseException; import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent; +import io.github.moulberry.notenoughupdates.recipes.EssenceUpgrades; +import io.github.moulberry.notenoughupdates.recipes.NeuRecipe; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.lang.reflect.Type; +import java.util.Map; import java.util.concurrent.locks.ReentrantLock; import java.util.regex.Pattern; @@ -94,10 +98,23 @@ public class Constants { TROPHYFISH = Utils.getConstant("trophyfish", gson); WEIGHT = Utils.getConstant("weight", gson); RNGSCORE = Utils.getConstant("rngscore", gson); + + parseEssenceCosts(); } catch (Exception ex) { ex.printStackTrace(); } finally { lock.unlock(); } } + + public void parseEssenceCosts() { + for (Map.Entry<String, JsonElement> entry : ESSENCECOSTS.entrySet()) { + NeuRecipe parsed = EssenceUpgrades.parseFromEssenceCostEntry(entry); + if (parsed != null) { + NotEnoughUpdates.INSTANCE.manager.registerNeuRecipe(parsed); + } else { + System.out.println("NULL for: " + entry); + } + } + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java index 6187495c..6cc1bbe7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java @@ -103,6 +103,22 @@ public class ItemUtils { is.setTagCompound(tagCompound); } + public static void setLore(ItemStack is, List<String> newLore) { + NBTTagCompound tagCompound = is.getTagCompound(); + if (tagCompound == null) { + tagCompound = new NBTTagCompound(); + } + + NBTTagCompound display = tagCompound.getCompoundTag("display"); + NBTTagList lore = new NBTTagList(); + for (String s : newLore) { + lore.appendTag(new NBTTagString(s)); + } + display.setTag("Lore", lore); + tagCompound.setTag("display", display); + is.setTagCompound(tagCompound); + } + public static List<String> getLore(ItemStack is) { return getLore(is.getTagCompound()); } |
