aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/mixins
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/mixins')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java25
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java25
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java92
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java53
4 files changed, 195 insertions, 0 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java
new file mode 100644
index 0000000..3cdbae5
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEndermanRenderer.java
@@ -0,0 +1,25 @@
+package com.thatgravyboat.skyblockhud.mixins;
+
+import com.thatgravyboat.skyblockhud.SpecialColour;
+import com.thatgravyboat.skyblockhud.handlers.sbentities.EntityTypeHelper;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.entity.RenderEnderman;
+import net.minecraft.entity.monster.EntityEnderman;
+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 java.awt.*;
+
+@Mixin(RenderEnderman.class)
+public class MixinEndermanRenderer {
+
+ @Inject(method = "doRender(Lnet/minecraft/entity/monster/EntityEnderman;DDDFF)V", at = @At("HEAD"))
+ public void onRender(EntityEnderman entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci){
+ if (EntityTypeHelper.isZealot(entity)){
+ Color color = new Color(SpecialColour.specialToChromaRGB("255:255:0:48:255"));
+ GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 255f);
+ }
+ }
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java
new file mode 100644
index 0000000..93537ea
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java
@@ -0,0 +1,25 @@
+package com.thatgravyboat.skyblockhud.mixins;
+
+import com.thatgravyboat.skyblockhud.tracker.KillTrackerHandler;
+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 {
+ //Disabled as kill tracker stuff not fully added yet.
+ @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())) {
+ KillTrackerHandler.attackedEntities.add(position.entityHit.getUniqueID());
+ }
+ return position;
+ }
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java
new file mode 100644
index 0000000..ce7c228
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java
@@ -0,0 +1,92 @@
+package com.thatgravyboat.skyblockhud.mixins;
+
+import com.thatgravyboat.skyblockhud.SkyblockHud;
+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.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.*;
+
+@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 (SkyblockHud.config.renderer.hideArmor && SkyblockHud.hasSkyblockScoreboard()){
+ ci.cancel();
+ if (pre(ARMOR)) return;
+ post(ARMOR);
+ }
+ }
+
+ @Inject(method = "renderHealth", at = @At("HEAD"), cancellable = true, remap = false)
+ public void onRenderHealth(int width, int height, CallbackInfo ci){
+ if (SkyblockHud.config.renderer.hideHearts && SkyblockHud.hasSkyblockScoreboard()){
+ ci.cancel();
+ if (pre(HEALTH)) return;
+ post(HEALTH);
+ }
+ }
+
+ @Inject(method = "renderAir", at = @At("HEAD"), cancellable = true, remap = false)
+ public void onRenderAir(int width, int height, CallbackInfo ci){
+ if (SkyblockHud.config.renderer.hideAir && SkyblockHud.hasSkyblockScoreboard()){
+ ci.cancel();
+ if (pre(AIR)) return;
+ post(AIR);
+ }
+ }
+
+ @Inject(method = "renderHealthMount", at = @At("HEAD"), cancellable = true, remap = false)
+ public void onRenderHealthMount(int width, int height, CallbackInfo ci){
+ if (SkyblockHud.config.renderer.hideAnimalHearts && SkyblockHud.hasSkyblockScoreboard()){
+ ci.cancel();
+ if (pre(HEALTHMOUNT)) return;
+ post(HEALTHMOUNT);
+ }
+ }
+
+ @Inject(method = "renderExperience", at = @At("HEAD"), cancellable = true, remap = false)
+ public void onRenderExperience(int width, int height, CallbackInfo ci){
+ if (SkyblockHud.config.renderer.hideXpBar && SkyblockHud.hasSkyblockScoreboard()){
+ ci.cancel();
+ if (pre(EXPERIENCE)) return;
+ post(EXPERIENCE);
+ }
+ }
+
+ @Inject(method = "renderJumpBar", at = @At("HEAD"), cancellable = true, remap = false)
+ public void onRenderJumpBar(int width, int height, CallbackInfo ci){
+ if (SkyblockHud.config.renderer.hideXpBar && SkyblockHud.hasSkyblockScoreboard()){
+ ci.cancel();
+ if (pre(JUMPBAR)) return;
+ post(JUMPBAR);
+ }
+ }
+
+ @Inject(method = "renderFood", at = @At("HEAD"), cancellable = true, remap = false)
+ public void onRenderFood(int width, int height, CallbackInfo ci){
+ if (SkyblockHud.config.renderer.hideFood && SkyblockHud.hasSkyblockScoreboard()){
+ ci.cancel();
+ if (pre(FOOD)) return;
+ post(FOOD);
+ }
+ }
+
+ private boolean pre(RenderGameOverlayEvent.ElementType type)
+ {
+ return MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Pre(eventParent, type));
+ }
+ private void post(RenderGameOverlayEvent.ElementType type)
+ {
+ MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(eventParent, type));
+ }
+}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java
new file mode 100644
index 0000000..679da20
--- /dev/null
+++ b/src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java
@@ -0,0 +1,53 @@
+package com.thatgravyboat.skyblockhud.mixins;
+
+import net.minecraft.client.network.NetHandlerPlayClient;
+import net.minecraft.network.play.server.S3EPacketTeams;
+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 {
+
+ /* DISABLE UNTIL NEW SYSTEM
+ @Inject(method = "handleSetSlot", at = @At("HEAD"))
+ public void onHandleSetSlot(S2FPacketSetSlot packetIn, CallbackInfo ci){
+ if (SkyblockHud.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 eId = null;
+ int eLvl = -1;
+ if (extraAttributes.hasKey("enchantments")) {
+ NBTTagCompound enchantments = extraAttributes.getCompoundTag("enchantments");
+ if (enchantments.getKeySet().size() == 1) {
+ for (String e : enchantments.getKeySet()) { eId = e; break; }
+ if (eId != null) eLvl = enchantments.getInteger(eId);
+ }
+ }
+ TrackerHandler.onItemAdded(id, changeAmount, eId, eLvl);
+ }
+ }
+ }
+ }
+ }
+ */
+
+ @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();
+ }
+
+}