aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/mixins
diff options
context:
space:
mode:
authorThatGravyBoat <thatgravyboat@gmail.com>2021-07-27 04:38:13 -0230
committerThatGravyBoat <thatgravyboat@gmail.com>2021-07-27 04:38:13 -0230
commit7809a1362c9644c9bfb69d8563a13e3f1ed3354a (patch)
treed8e1a33db7656aa2aeaa9fcc44e2310df35b774d /src/main/java/com/thatgravyboat/skyblockhud/mixins
parent39749967fc92a3976b231285492d71f8782e93da (diff)
downloadSkyblockHud-Death-Defied-7809a1362c9644c9bfb69d8563a13e3f1ed3354a.tar.gz
SkyblockHud-Death-Defied-7809a1362c9644c9bfb69d8563a13e3f1ed3354a.tar.bz2
SkyblockHud-Death-Defied-7809a1362c9644c9bfb69d8563a13e3f1ed3354a.zip
Added Dynamic Item Cooldowns.
Updated Profile Events to contain profile name. Added copy NPC skin command. Added warphandler gives me access to what warps you have. Moved all config and data files into its own folder. Added option to turn off adding back overflow mana.
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/mixins')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/GuiChestAccessor.java13
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java42
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java41
3 files changed, 96 insertions, 0 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/GuiChestAccessor.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/GuiChestAccessor.java
new file mode 100644
index 0000000..a300f9e
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/GuiChestAccessor.java
@@ -0,0 +1,13 @@
+package com.thatgravyboat.skyblockhud.mixins;
+
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.inventory.IInventory;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+@Mixin(GuiChest.class)
+public interface GuiChestAccessor {
+
+ @Accessor
+ IInventory getLowerChestInventory();
+}
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 0000000..1f372ad
--- /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;
+ }
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java
new file mode 100644
index 0000000..08f9314
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java
@@ -0,0 +1,41 @@
+package com.thatgravyboat.skyblockhud.mixins;
+
+import com.thatgravyboat.skyblockhud.handlers.CooldownHandler;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.WorldRenderer;
+import net.minecraft.client.renderer.entity.RenderItem;
+import net.minecraft.item.ItemStack;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Mixin(RenderItem.class)
+public abstract class MixinRenderItem {
+
+ @Shadow protected abstract void draw(WorldRenderer renderer, int x, int y, int width, int height, int red, int green, int blue, int alpha);
+
+ @Inject(method="renderItemOverlayIntoGUI", at=@At("RETURN"))
+ public void renderItemOverlayIntoGUI(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text, CallbackInfo ci) {
+ if(stack == null) return;
+ float cooldown = CooldownHandler.getAbilityTime(stack);
+
+ if (cooldown > -1){
+ GlStateManager.disableLighting();
+ GlStateManager.disableDepth();
+ GlStateManager.disableTexture2D();
+ GlStateManager.disableAlpha();
+ GlStateManager.disableBlend();
+ WorldRenderer worldrenderer = Tessellator.getInstance().getWorldRenderer();
+ this.draw(worldrenderer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
+ this.draw(worldrenderer, xPosition + 2, yPosition + 13, Math.round(cooldown * 13f), 1, 102, 102, 255, 255);
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableLighting();
+ GlStateManager.enableDepth();
+ }
+ }
+}