aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java
diff options
context:
space:
mode:
authorMoulberry <james.jenour@student.scotch.wa.edu.au>2020-11-08 17:44:27 +1100
committerMoulberry <james.jenour@student.scotch.wa.edu.au>2020-11-08 17:44:27 +1100
commit07403ec86c53f67b94d988b4c01a0afc2fdb2810 (patch)
treefba4b3c37b02c42267e03a07453d3941c98fd66d /src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java
parentfc4143dd3c892b11ae5f427fcecc22044ff98460 (diff)
parentec0660e41145d3d9ed479b3e697afddf8ddc8c4c (diff)
downloadnotenoughupdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.tar.gz
notenoughupdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.tar.bz2
notenoughupdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.zip
Merge branch 'beta'
uh yeah its pretty necessary guys
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java b/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java
new file mode 100644
index 00000000..8ec4263a
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java
@@ -0,0 +1,60 @@
+package io.github.moulberry.notenoughupdates;
+
+import io.github.moulberry.morus.MorusSubstitutor;
+import net.minecraft.client.Minecraft;
+import net.minecraft.item.ItemStack;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MorusIntegration {
+
+ private static MorusIntegration INSTANCE = new MorusIntegration();
+
+ public static MorusIntegration getInstance() {
+ return INSTANCE;
+ }
+
+ private HashMap<String, Integer> itemDrops = null;
+ private HashMap<String, Integer> inventoryItems = null;
+
+ public void tick() {
+ if(itemDrops == null) {
+ itemDrops = new HashMap<>();
+ for(String item : NotEnoughUpdates.INSTANCE.manager.getItemInformation().keySet()) {
+ itemDrops.put(item, 0);
+ }
+ }
+
+ HashMap<String, Integer> newInventoryItems = getInventoryItems();
+ if(inventoryItems != null) {
+ for(String internal : newInventoryItems.keySet()) {
+ int newAmount = newInventoryItems.get(internal);
+ int oldAmount = inventoryItems.getOrDefault(internal, 0);
+ if(newAmount > oldAmount) {
+ itemDrops.put(internal, itemDrops.getOrDefault(internal, 0)+newAmount-oldAmount);
+ }
+ }
+ }
+ inventoryItems = newInventoryItems;
+
+ for(Map.Entry<String, Integer> entry : itemDrops.entrySet()) {
+ MorusSubstitutor.putSubstiution("notenoughupdates", "itemdrops."+entry.getKey().toLowerCase(), ""+entry.getValue());
+ }
+
+ }
+
+ public HashMap<String, Integer> getInventoryItems() {
+ HashMap<String, Integer> inventoryItems = new HashMap<>();
+ if(Minecraft.getMinecraft().thePlayer != null) {
+ for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ if(internalname != null) {
+ inventoryItems.put(internalname, inventoryItems.getOrDefault(internalname, 0)+stack.stackSize);
+ }
+ }
+ }
+ return inventoryItems;
+ }
+
+}