aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Features.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java81
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/HideArmor.kt216
4 files changed, 288 insertions, 16 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index 6335a8285..fc75549d1 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -132,6 +132,7 @@ public class SkyHanniMod {
registerEvent(new HideDamageSplash());
registerEvent(new ThunderSparksHighlight());
registerEvent(new PlayerChatFilter());
+ registerEvent(new HideArmor());
Commands.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java
index 3e5c4af7f..9fad399ec 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Features.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.config.core.config.Position;
import at.hannibal2.skyhanni.config.core.config.annotations.Category;
import at.hannibal2.skyhanni.config.core.config.gui.GuiPositionEditor;
import at.hannibal2.skyhanni.config.features.*;
+import at.hannibal2.skyhanni.features.HideArmor;
import at.hannibal2.skyhanni.features.MarkedPlayerManager;
import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFormatter;
import com.google.gson.annotations.Expose;
@@ -101,6 +102,11 @@ public class Features extends Config {
MarkedPlayerManager.toggleOwn();
return;
}
+
+ if (runnableId.equals("hideArmor")) {
+ HideArmor.Companion.updateArmor();
+ return;
+ }
}
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index d8b08a0ec..0cab88e7a 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -1,60 +1,109 @@
package at.hannibal2.skyhanni.config.features;
import at.hannibal2.skyhanni.config.core.config.Position;
-import at.hannibal2.skyhanni.config.core.config.annotations.ConfigEditorBoolean;
-import at.hannibal2.skyhanni.config.core.config.annotations.ConfigEditorButton;
-import at.hannibal2.skyhanni.config.core.config.annotations.ConfigOption;
+import at.hannibal2.skyhanni.config.core.config.annotations.*;
import com.google.gson.annotations.Expose;
public class Misc {
@Expose
+ @ConfigOption(name = "Pet", desc = "")
+ @ConfigEditorAccordion(id = 0)
+ public boolean pet = false;
+
+ @Expose
@ConfigOption(name = "Pet Display", desc = "Show the currently active pet.")
@ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
public boolean petDisplay = false;
@Expose
@ConfigOption(name = "Pet Display Position", desc = "")
@ConfigEditorButton(runnableId = "petDisplay", buttonText = "Edit")
+ @ConfigAccordionId(id = 0)
public Position petDisplayPos = new Position(10, 10, false, true);
@Expose
- @ConfigOption(name = "Exp Bottles", desc = "Hides all the experience bottles lying on the ground.")
- @ConfigEditorBoolean
- public boolean hideExpBottles = false;
-
- @Expose
- @ConfigOption(name = "Skytils Damage Splash", desc = "Fixing the custom damage splash feature from skytils.")
- @ConfigEditorBoolean
- public boolean fixSkytilsDamageSplash = true;
-
- @Expose
- @ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.")
- @ConfigEditorBoolean
- public boolean configButtonOnPause = true;
+ @ConfigOption(name = "Time", desc = "")
+ @ConfigEditorAccordion(id = 1)
+ public boolean time = false;
@Expose
@ConfigOption(name = "Real Time", desc = "Show the real time. Useful while playing in full screen mode")
@ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
public boolean realTime = false;
@Expose
@ConfigOption(name = "Real Time Position", desc = "")
@ConfigEditorButton(runnableId = "realTime", buttonText = "Edit")
+ @ConfigAccordionId(id = 1)
public Position realTimePos = new Position(10, 10, false, true);
@Expose
+ @ConfigOption(name = "Highlight Mobs", desc = "")
+ @ConfigEditorAccordion(id = 2)
+ public boolean highlightColor = false;
+
+ @Expose
@ConfigOption(name = "Voidling Extremist Color", desc = "Highlight the voidling extremist in pink color")
@ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
public boolean voidlingExtremistColor = false;
@Expose
@ConfigOption(name = "Corrupted Mob Highlight", desc = "Highlight corrupted mobs in purple color")
@ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
public boolean corruptedMobHighlight = false;
@Expose
+ @ConfigOption(name = "Hide Armor", desc = "")
+ @ConfigEditorAccordion(id = 3)
+ public boolean hideArmor = false;
+
+ @Expose
+ @ConfigOption(name = "Hide Armor", desc = "Hide the armor of players.")
+ @ConfigEditorBoolean(runnableId = "hideArmor")
+ @ConfigAccordionId(id = 3)
+ public boolean hideArmorEnabled = false;
+
+ @Expose
+ @ConfigOption(name = "Own Armor", desc = "Hide the armor of yourself.")
+ @ConfigEditorBoolean(runnableId = "hideArmor")
+ @ConfigAccordionId(id = 3)
+ public boolean hideArmorOwn = true;
+
+ @Expose
+ @ConfigOption(name = "Only Helmet", desc = "Hide only the helmet.")
+ @ConfigEditorBoolean(runnableId = "hideArmor")
+ @ConfigAccordionId(id = 3)
+ public boolean hideArmorOnlyHelmet = false;
+
+ @Expose
+ @ConfigOption(name = "Damage Splash", desc = "")
+ @ConfigEditorAccordion(id = 4)
+ public boolean damageSplash = false;
+
+ @Expose
+ @ConfigOption(name = "Skytils Damage Splash", desc = "Fixing the custom damage splash feature from skytils.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 4)
+ public boolean fixSkytilsDamageSplash = true;
+
+ @Expose
@ConfigOption(name = "Hide Damage Splash", desc = "Hide all damage splashes, from anywhere in Skyblock.")
@ConfigEditorBoolean
+ @ConfigAccordionId(id = 4)
public boolean hideDamageSplash = false;
+
+ @Expose
+ @ConfigOption(name = "Exp Bottles", desc = "Hides all the experience bottles lying on the ground.")
+ @ConfigEditorBoolean
+ public boolean hideExpBottles = false;
+
+ @Expose
+ @ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.")
+ @ConfigEditorBoolean
+ public boolean configButtonOnPause = true;
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/HideArmor.kt b/src/main/java/at/hannibal2/skyhanni/features/HideArmor.kt
new file mode 100644
index 000000000..a95aa02b7
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/HideArmor.kt
@@ -0,0 +1,216 @@
+package at.hannibal2.skyhanni.features
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.client.Minecraft
+import net.minecraft.client.entity.EntityOtherPlayerMP
+import net.minecraft.client.entity.EntityPlayerSP
+import net.minecraft.client.gui.inventory.GuiInventory
+import net.minecraft.entity.player.EntityPlayer
+import net.minecraft.item.ItemStack
+import net.minecraft.network.play.server.S04PacketEntityEquipment
+import net.minecraft.network.play.server.S2FPacketSetSlot
+import net.minecraft.network.play.server.S30PacketWindowItems
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+
+class HideArmor {
+
+ private var invOpen = false
+ private val laterCheck = mutableListOf<Int>()
+
+ @SubscribeEvent
+ fun onGuiInventoryToggle(event: TickEvent.ClientTickEvent) {
+ if (!LorenzUtils.inSkyblock) return // TODO test this
+
+ fixOtherArmor()
+
+ if (!SkyHanniMod.feature.misc.hideArmorEnabled) return
+
+ val currentScreen = Minecraft.getMinecraft().currentScreen
+ if (currentScreen == null || currentScreen !is GuiInventory) {
+ if (invOpen) {
+ invOpen = false
+ changeArmor(Minecraft.getMinecraft().thePlayer, null)
+ }
+ } else {
+ if (!invOpen) {
+ invOpen = true
+ val thePlayer = Minecraft.getMinecraft().thePlayer
+ val entityId = thePlayer.entityId
+ changeArmor(thePlayer, getCachedArmor(entityId))
+ }
+ }
+ }
+
+ // Since S04PacketEntityEquipment gets sent before the entity is fully loaded, I need to remove the armor later
+ private fun fixOtherArmor() {
+ for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList) {
+ if (entity !is EntityOtherPlayerMP) continue
+
+ val entityId = entity.entityId
+ if (entityId !in laterCheck) continue
+
+ laterCheck.remove(entityId)
+ if (SkyHanniMod.feature.misc.hideArmorEnabled) {
+ val armorInventory = entity.inventory.armorInventory
+ for ((equipmentSlot, _) in armorInventory.withIndex()) {
+ if (!SkyHanniMod.feature.misc.hideArmorOnlyHelmet || equipmentSlot == 3) {
+ armorInventory[equipmentSlot] = null
+ }
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onPacketReceive(event: PacketEvent.ReceiveEvent) {
+ val packet = event.packet
+
+ //own player world switch
+ if (packet is S30PacketWindowItems) {
+
+ // check window id
+ if (packet.func_148911_c() != 0) return
+
+ for ((slot, itemStack) in packet.itemStacks.withIndex()) {
+
+ if (slot !in 5..8) continue
+
+ val armorSlot = (slot - 5) * -1 + 3
+ val armor = getCachedArmor(Minecraft.getMinecraft().thePlayer.entityId)
+ armor[armorSlot] = itemStack
+
+ val currentScreen = Minecraft.getMinecraft().currentScreen
+ if (currentScreen == null || currentScreen !is GuiInventory) {
+ if (SkyHanniMod.feature.misc.hideArmorEnabled) {
+ if (SkyHanniMod.feature.misc.hideArmorOwn) {
+ if (!SkyHanniMod.feature.misc.hideArmorOnlyHelmet || armorSlot == 3) {
+ packet.itemStacks[slot] = null
+ }
+ }
+ }
+ }
+ }
+ return
+ }
+
+
+ //own player armor change
+ if (packet is S2FPacketSetSlot) {
+ val slot = packet.func_149173_d()
+
+ // check window id
+ if (packet.func_149175_c() != 0) return
+ if (slot !in 5..8) return
+
+ val armorSlot = (slot - 5) * -1 + 3
+ val armor = getCachedArmor(Minecraft.getMinecraft().thePlayer.entityId)
+ // set item in cache
+ armor[armorSlot] = packet.func_149174_e()
+
+ val currentScreen = Minecraft.getMinecraft().currentScreen
+ if (currentScreen == null || currentScreen !is GuiInventory) {
+ if (SkyHanniMod.feature.misc.hideArmorEnabled) {
+ if (SkyHanniMod.feature.misc.hideArmorOwn) {
+ if (!SkyHanniMod.feature.misc.hideArmorOnlyHelmet || armorSlot == 3) {
+ event.isCanceled = true
+ }
+ }
+ }
+ }
+ return
+ }
+
+
+ //other player armor switch
+ if (packet is S04PacketEntityEquipment) {
+ val entityID = packet.entityID
+ val equipmentSlot = packet.equipmentSlot - 1
+ if (equipmentSlot == -1) return
+
+ val entity = Minecraft.getMinecraft().theWorld.getEntityByID(entityID)
+ if (entity == null) {
+ laterCheck.add(entityID)
+ return
+ }
+
+ if (entity !is EntityOtherPlayerMP) return
+
+ val armor = getCachedArmor(entityID)
+
+ // set item in cache
+ armor[equipmentSlot] = packet.itemStack
+
+ if (SkyHanniMod.feature.misc.hideArmorEnabled) {
+ if (!SkyHanniMod.feature.misc.hideArmorOnlyHelmet || equipmentSlot == 3) {
+ event.isCanceled = true
+ }
+ }
+ }
+ }
+
+ private fun getCachedArmor(entityID: Int): Array<ItemStack?> {
+ val armor: Array<ItemStack?> = if (armorCache.containsKey(entityID)) {
+ armorCache[entityID]!!
+ } else {
+ val new = arrayOf<ItemStack?>(null, null, null, null)
+ armorCache[entityID] = new
+ new
+ }
+ return armor
+ }
+
+ companion object {
+ var armorCache: MutableMap<Int, Array<ItemStack?>> = mutableMapOf()
+
+ fun updateArmor() {
+ for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList) {
+ if (entity !is EntityPlayer) continue
+
+ val entityId = entity.entityId
+ armorCache[entityId]?.let {
+ changeArmor(entity, it)
+ }
+
+ if (SkyHanniMod.feature.misc.hideArmorEnabled) {
+ changeArmor(entity, null)
+ }
+ }
+ }
+
+ private fun changeArmor(entity: EntityPlayer, new: Array<ItemStack?>?) {
+ if (!LorenzUtils.inSkyblock) return
+
+ val current = entity.inventory.armorInventory
+ if (new != null) {
+ current[0] = new[0]
+ current[1] = new[1]
+ current[2] = new[2]
+ current[3] = new[3]
+ return
+ }
+
+ if (!SkyHanniMod.feature.misc.hideArmorOwn) {
+ if (entity is EntityPlayerSP) {
+ return
+ }
+ }
+
+ if (!SkyHanniMod.feature.misc.hideArmorOnlyHelmet) {
+ current[0] = null
+ current[1] = null
+ current[2] = null
+ }
+ current[3] = null
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ armorCache.clear()
+ laterCheck.clear()
+ }
+} \ No newline at end of file