diff options
author | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-09-27 14:17:41 -0230 |
---|---|---|
committer | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-09-27 14:17:41 -0230 |
commit | f1fd06d889162ac72395ef66043970cfe42cde5e (patch) | |
tree | 1e306d5817eac77ac44ef59085120882f8824d7a /src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java | |
parent | 7809a1362c9644c9bfb69d8563a13e3f1ed3354a (diff) | |
download | skyblockhud-f1fd06d889162ac72395ef66043970cfe42cde5e.tar.gz skyblockhud-f1fd06d889162ac72395ef66043970cfe42cde5e.tar.bz2 skyblockhud-f1fd06d889162ac72395ef66043970cfe42cde5e.zip |
I dont even know when I coded this.
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java')
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java index dd6adb2..e7dacd4 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java @@ -3,11 +3,15 @@ package com.thatgravyboat.skyblockhud.location; import com.thatgravyboat.skyblockhud.api.events.SidebarLineUpdateEvent; import com.thatgravyboat.skyblockhud.api.events.SidebarPostEvent; import com.thatgravyboat.skyblockhud.overlay.MiningHud; +import com.thatgravyboat.skyblockhud.utils.Utils; +import java.lang.ref.WeakReference; import java.math.RoundingMode; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.Arrays; import java.util.Locale; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class MinesHandler { @@ -153,4 +157,35 @@ public class MinesHandler { MiningHud.setHeat(0); } } + + public static WeakReference<PrehistoricEggProgress> getEggColorAndProgress(ItemStack stack) { + String id = Utils.getItemCustomId(stack); + if (id == null || !id.equals("PREHISTORIC_EGG")) return null; + NBTTagCompound extraAttributes = stack.getTagCompound().getCompoundTag("ExtraAttributes"); + if (!extraAttributes.hasKey("blocks_walked")) return null; + PrehistoricEggProgress progress = new PrehistoricEggProgress(); + int walked = extraAttributes.getInteger("blocks_walked"); + if (walked < 4000) { + progress.currentColor = 0xffffff; + progress.progress = walked / 4000f; + }else if (walked < 10000) { + progress.currentColor = 0x55FF55; + progress.progress = (walked - 4000f) / 6000f; + }else if (walked < 20000) { + progress.currentColor = 0x5555FF; + progress.progress = (walked - 10000f) / 10000f; + }else if (walked < 40000) { + progress.currentColor = 0xAA00AA; + progress.progress = (walked - 20000f) / 20000f; + }else if (walked < 100000) { + progress.currentColor = 0xFFAA00; + progress.progress = (walked - 40000f) / 60000f; + } + return new WeakReference<>(progress); + } + + public static class PrehistoricEggProgress { + public float progress; + public int currentColor; + } } |