aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud_2/mixins
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-08 16:12:55 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-08 16:12:55 +0200
commit4463c7fa78f886a8abc09e867dd17cde2a685ad4 (patch)
tree9245b4eed7f410f1c168688a77eeda6bfd55c994 /src/main/java/com/thatgravyboat/skyblockhud_2/mixins
parent9e08dbf2baa9819abd281ad285df7462c99491e2 (diff)
downloadskyhanni-4463c7fa78f886a8abc09e867dd17cde2a685ad4.tar.gz
skyhanni-4463c7fa78f886a8abc09e867dd17cde2a685ad4.tar.bz2
skyhanni-4463c7fa78f886a8abc09e867dd17cde2a685ad4.zip
code cleanup
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud_2/mixins')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud_2/mixins/GuiChestAccessor.java12
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinEntityArrow.java26
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinGuiIngameForge.java113
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinItemStack.java42
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinNetHandlerPlayClient.java67
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinRenderItem.java63
6 files changed, 323 insertions, 0 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/GuiChestAccessor.java b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/GuiChestAccessor.java
new file mode 100644
index 000000000..1dc3d336e
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/GuiChestAccessor.java
@@ -0,0 +1,12 @@
+package com.thatgravyboat.skyblockhud_2.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_2/mixins/MixinEntityArrow.java b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinEntityArrow.java
new file mode 100644
index 000000000..d892c01f1
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinEntityArrow.java
@@ -0,0 +1,26 @@
+//package com.thatgravyboat.skyblockhud.mixins;
+//
+//import com.thatgravyboat.skyblockhud.api.KillTracking;
+//import net.minecraft.client.Minecraft;
+//import net.minecraft.entity.Entity;
+//import net.minecraft.entity.projectile.EntityArrow;
+//import net.minecraft.util.MovingObjectPosition;
+//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.ModifyVariable;
+//
+//@Mixin(EntityArrow.class)
+//public class MixinEntityArrow {
+//
+// @Shadow
+// public Entity shootingEntity;
+//
+// @ModifyVariable(method = "onUpdate", at = @At(value = "STORE", ordinal = 1))
+// public MovingObjectPosition onUpdate(MovingObjectPosition position) {
+// if (position != null && position.entityHit != null && this.shootingEntity != null && this.shootingEntity.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) {
+// KillTracking.attackedEntities.add(position.entityHit.getUniqueID());
+// }
+// return position;
+// }
+//}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinGuiIngameForge.java b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinGuiIngameForge.java
new file mode 100644
index 000000000..078bdce8f
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinGuiIngameForge.java
@@ -0,0 +1,113 @@
+//package com.thatgravyboat.skyblockhud.mixins;
+//
+//import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.*;
+//
+//import at.lorenz.mod.LorenzMod;
+//import com.thatgravyboat.skyblockhud.overlay.MiningHud;
+//import com.thatgravyboat.skyblockhud.utils.Utils;
+//import net.minecraft.client.Minecraft;
+//import net.minecraftforge.client.GuiIngameForge;
+//import net.minecraftforge.client.event.RenderGameOverlayEvent;
+//import net.minecraftforge.common.MinecraftForge;
+//import org.spongepowered.asm.mixin.Mixin;
+//import org.spongepowered.asm.mixin.Shadow;
+//import org.spongepowered.asm.mixin.Unique;
+//import org.spongepowered.asm.mixin.injection.At;
+//import org.spongepowered.asm.mixin.injection.Inject;
+//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+//
+//@Mixin(GuiIngameForge.class)
+//public class MixinGuiIngameForge {
+//
+// @Shadow(remap = false)
+// private RenderGameOverlayEvent eventParent;
+//
+// @Inject(method = "renderArmor", at = @At("HEAD"), cancellable = true, remap = false)
+// public void onRenderArmor(int width, int height, CallbackInfo ci) {
+// if (LorenzMod.config.renderer.hideArmor && LorenzMod.hasSkyblockScoreboard()) {
+// ci.cancel();
+// if (prePost(ARMOR, eventParent)) return;
+// postPost(ARMOR, eventParent);
+// }
+// }
+//
+// @Inject(method = "renderHealth", at = @At("HEAD"), cancellable = true, remap = false)
+// public void onRenderHealth(int width, int height, CallbackInfo ci) {
+// if (LorenzMod.config.renderer.hideHearts && LorenzMod.hasSkyblockScoreboard()) {
+// ci.cancel();
+// if (prePost(HEALTH, eventParent)) return;
+// postPost(HEALTH, eventParent);
+// }
+// }
+//
+// @Inject(method = "renderAir", at = @At("HEAD"), cancellable = true, remap = false)
+// public void onRenderAir(int width, int height, CallbackInfo ci) {
+// if (LorenzMod.config.renderer.hideAir && LorenzMod.hasSkyblockScoreboard()) {
+// ci.cancel();
+// if (prePost(AIR, eventParent)) return;
+// postPost(AIR, eventParent);
+// }
+// }
+//
+// @Inject(method = "renderHealthMount", at = @At("HEAD"), cancellable = true, remap = false)
+// public void onRenderHealthMount(int width, int height, CallbackInfo ci) {
+// if (LorenzMod.config.renderer.hideAnimalHearts && LorenzMod.hasSkyblockScoreboard()) {
+// ci.cancel();
+// if (prePost(HEALTHMOUNT, eventParent)) return;
+// postPost(HEALTHMOUNT, eventParent);
+// }
+// }
+//
+// @Inject(method = "renderExperience", at = @At("HEAD"), cancellable = true, remap = false)
+// public void onRenderExperience(int width, int height, CallbackInfo ci) {
+// if (LorenzMod.config.renderer.hideXpBar && LorenzMod.hasSkyblockScoreboard()) {
+// ci.cancel();
+// if (prePost(EXPERIENCE, eventParent)) return;
+// postPost(EXPERIENCE, eventParent);
+// } else if (LorenzMod.config.mining.barMode == 1) {
+// if (!LorenzMod.config.renderer.hideXpBar && (LorenzMod.config.mining.showDrillBar || LorenzMod.config.mining.showHeatBar) && LorenzMod.hasSkyblockScoreboard()) {
+// if (MiningHud.getHeat() > 0 || Utils.isDrill(Minecraft.getMinecraft().thePlayer.getHeldItem())) {
+// ci.cancel();
+// if (prePost(EXPERIENCE, eventParent)) return;
+// postPost(EXPERIENCE, eventParent);
+// }
+// }
+// }
+// }
+//
+// @Inject(method = "renderJumpBar", at = @At("HEAD"), cancellable = true, remap = false)
+// public void onRenderJumpBar(int width, int height, CallbackInfo ci) {
+// if (LorenzMod.config.renderer.hideXpBar && LorenzMod.hasSkyblockScoreboard()) {
+// ci.cancel();
+// if (prePost(JUMPBAR, eventParent)) return;
+// postPost(JUMPBAR, eventParent);
+// } else if (LorenzMod.config.mining.barMode == 1) {
+// if (!LorenzMod.config.renderer.hideXpBar && (LorenzMod.config.mining.showDrillBar || LorenzMod.config.mining.showHeatBar) && LorenzMod.hasSkyblockScoreboard()) {
+// if (MiningHud.getHeat() > 0 || Utils.isDrill(Minecraft.getMinecraft().thePlayer.getHeldItem())) {
+// ci.cancel();
+// if (prePost(JUMPBAR, eventParent)) return;
+// postPost(JUMPBAR, eventParent);
+// }
+// }
+// }
+// }
+//
+// @Inject(method = "renderFood", at = @At("HEAD"), cancellable = true, remap = false)
+// public void onRenderFood(int width, int height, CallbackInfo ci) {
+// if (LorenzMod.config.renderer.hideFood && LorenzMod.hasSkyblockScoreboard()) {
+// ci.cancel();
+// if (prePost(FOOD, eventParent)) return;
+// postPost(FOOD, eventParent);
+// }
+// }
+//
+// @Unique
+// private static boolean prePost(RenderGameOverlayEvent.ElementType type, RenderGameOverlayEvent eventParent) {
+// return MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Pre(eventParent, type));
+// }
+//
+// @Unique
+// private static void postPost(RenderGameOverlayEvent.ElementType type, RenderGameOverlayEvent eventParent) {
+// MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(eventParent, type));
+// }
+//}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinItemStack.java b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinItemStack.java
new file mode 100644
index 000000000..eef185561
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinItemStack.java
@@ -0,0 +1,42 @@
+//package com.thatgravyboat.skyblockhud.mixins;
+//
+//import at.lorenz.mod.LorenzMod;
+//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 (LorenzMod.config != null && !LorenzMod.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_2/mixins/MixinNetHandlerPlayClient.java b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinNetHandlerPlayClient.java
new file mode 100644
index 000000000..9d5bf57bc
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinNetHandlerPlayClient.java
@@ -0,0 +1,67 @@
+//package com.thatgravyboat.skyblockhud.mixins;
+//
+//import at.lorenz.mod.LorenzMod;
+//import com.thatgravyboat.skyblockhud.tracker.TrackerHandler;
+//import net.minecraft.client.Minecraft;
+//import net.minecraft.client.network.NetHandlerPlayClient;
+//import net.minecraft.item.ItemStack;
+//import net.minecraft.nbt.NBTTagCompound;
+//import net.minecraft.network.PacketThreadUtil;
+//import net.minecraft.network.play.server.S2FPacketSetSlot;
+//import net.minecraft.network.play.server.S3EPacketTeams;
+//import net.minecraft.scoreboard.ScorePlayerTeam;
+//import net.minecraft.scoreboard.Scoreboard;
+//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;
+//import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
+//
+//@Mixin(NetHandlerPlayClient.class)
+//public class MixinNetHandlerPlayClient {
+//
+// @Inject(method = "handleSetSlot", at = @At("HEAD"))
+// public void onHandleSetSlot(S2FPacketSetSlot packetIn, CallbackInfo ci) {
+// if (LorenzMod.hasSkyblockScoreboard()) {
+// Minecraft mc = Minecraft.getMinecraft();
+// PacketThreadUtil.checkThreadAndEnqueue(packetIn, mc.getNetHandler(), mc);
+// if (packetIn.func_149175_c() == 0) {
+// ItemStack stack = packetIn.func_149174_e();
+//
+// if (stack != null && stack.hasTagCompound()) {
+// if (stack.getTagCompound().hasKey("ExtraAttributes")) {
+// NBTTagCompound extraAttributes = stack.getTagCompound().getCompoundTag("ExtraAttributes");
+// String id = extraAttributes.getString("id");
+// ItemStack slotStack = Minecraft.getMinecraft().thePlayer.inventoryContainer.getSlot(packetIn.func_149173_d()).getStack();
+// int changeAmount = stack.stackSize - (slotStack == null ? 0 : slotStack.stackSize);
+// String specialId = null;
+// int number = -1;
+// if (extraAttributes.hasKey("enchantments")) {
+// NBTTagCompound enchantments = extraAttributes.getCompoundTag("enchantments");
+// if (enchantments.getKeySet().size() == 1) {
+// for (String e : enchantments.getKeySet()) {
+// specialId = e;
+// break;
+// }
+// if (specialId != null) number = enchantments.getInteger(specialId);
+// }
+// }
+// TrackerHandler.onItemAdded(id, changeAmount, specialId, number);
+// }
+// }
+// }
+// }
+// }
+//
+// @Inject(method = "handleTeams", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/server/S3EPacketTeams;getAction()I", ordinal = 0, shift = At.Shift.BEFORE), cancellable = true)
+// public void handleTeams(S3EPacketTeams packetIn, CallbackInfo ci, Scoreboard scoreboard) {
+// //This stops Hypixel from being stupid and spamming our logs because they dont have different ids for things.
+// if (scoreboard.getTeam(packetIn.getName()) != null && packetIn.getAction() == 0) ci.cancel();
+// }
+//
+// @Inject(method = "handleTeams", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/network/play/server/S3EPacketTeams;getAction()I", ordinal = 6, shift = At.Shift.BEFORE), cancellable = true)
+// public void handleTeamRemove(S3EPacketTeams packetIn, CallbackInfo ci, Scoreboard scoreboard, ScorePlayerTeam scoreplayerteam) {
+// //This stops Hypixel from being stupid and spamming our logs because they dont have different ids for things.
+// if (scoreplayerteam == null) ci.cancel();
+// }
+//}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinRenderItem.java b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinRenderItem.java
new file mode 100644
index 000000000..64f9086fb
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud_2/mixins/MixinRenderItem.java
@@ -0,0 +1,63 @@
+//package com.thatgravyboat.skyblockhud.mixins;
+//
+//import com.thatgravyboat.skyblockhud.handlers.CooldownHandler;
+//import com.thatgravyboat.skyblockhud.location.MinesHandler;
+//import java.lang.ref.WeakReference;
+//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);
+//
+// WeakReference<MinesHandler.PrehistoricEggProgress> weakProgress = MinesHandler.getEggColorAndProgress(stack);
+//
+// if (weakProgress != null) {
+// MinesHandler.PrehistoricEggProgress progress = weakProgress.get();
+// if (progress == null) return;
+// 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(progress.progress * 13f), 1, (progress.currentColor >> 16) & 0xFF, (progress.currentColor >> 8) & 0xFF, progress.currentColor & 0xFF, 255);
+// GlStateManager.enableAlpha();
+// GlStateManager.enableTexture2D();
+// GlStateManager.enableLighting();
+// GlStateManager.enableDepth();
+// }
+//
+// 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();
+// }
+// }
+//}