diff options
| author | Lulonaut <lulonaut@tutanota.de> | 2022-11-02 00:35:02 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-02 00:35:02 +0100 |
| commit | abe71be0da84bfc5d765c002cea4bf1950fe49e1 (patch) | |
| tree | b0f30fc651fcdfe5d2725141a6380c53e2b7e546 /src/main/java/io/github/moulberry/notenoughupdates/util | |
| parent | 7184121f7ae1f16a9bc8e51989f555d62b14bb24 (diff) | |
| download | notenoughupdates-abe71be0da84bfc5d765c002cea4bf1950fe49e1.tar.gz notenoughupdates-abe71be0da84bfc5d765c002cea4bf1950fe49e1.tar.bz2 notenoughupdates-abe71be0da84bfc5d765c002cea4bf1950fe49e1.zip | |
Essenceupgrades gui (#313)
Co-authored-by: jani270 <jani270@gmx.de>
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()); } |
