aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-07 00:31:50 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-07 00:31:50 +0200
commit99773d6a593c444151503de315f127bea6f74d49 (patch)
tree9ee1ae505e5f82aba62f10c882af85a3acd6e483 /src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java
downloadskyhanni-99773d6a593c444151503de315f127bea6f74d49.tar.gz
skyhanni-99773d6a593c444151503de315f127bea6f74d49.tar.bz2
skyhanni-99773d6a593c444151503de315f127bea6f74d49.zip
init lorenz mod
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java
new file mode 100644
index 000000000..1f372ad40
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java
@@ -0,0 +1,42 @@
+package com.thatgravyboat.skyblockhud.mixins;
+
+import com.thatgravyboat.skyblockhud.SkyblockHud;
+import com.thatgravyboat.skyblockhud.api.item.IAbility;
+import com.thatgravyboat.skyblockhud.handlers.CooldownHandler;
+import java.util.regex.Matcher;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Mixin(ItemStack.class)
+public class MixinItemStack implements IAbility {
+
+ private String ability;
+ private int abilityTime;
+
+ @Inject(method = "setTagCompound", at = @At("HEAD"))
+ public void onNbt(NBTTagCompound nbt, CallbackInfo ci) {
+ if (SkyblockHud.config != null && !SkyblockHud.config.misc.hideItemCooldowns) {
+ Matcher abilityMatcher = CooldownHandler.getAbility(nbt);
+ if (abilityMatcher != null) {
+ ability = abilityMatcher.group(1);
+ try {
+ abilityTime = Integer.parseInt(abilityMatcher.group(2).trim());
+ } catch (Exception ignored) {}
+ }
+ }
+ }
+
+ @Override
+ public String getAbility() {
+ return ability;
+ }
+
+ @Override
+ public int getAbilityTime() {
+ return abilityTime;
+ }
+}