diff options
author | Lorenz <ESs95s3P5z8Pheb> | 2022-07-07 00:31:50 +0200 |
---|---|---|
committer | Lorenz <ESs95s3P5z8Pheb> | 2022-07-07 00:31:50 +0200 |
commit | 99773d6a593c444151503de315f127bea6f74d49 (patch) | |
tree | 9ee1ae505e5f82aba62f10c882af85a3acd6e483 /src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java | |
download | skyhanni-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.java | 42 |
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; + } +} |