aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Ashfang.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtTimeEvent.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt53
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHighlightBlazes.kt85
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt31
8 files changed, 166 insertions, 40 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index d77c4f9cc..4407eb7f8 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -28,10 +28,7 @@ import at.hannibal2.skyhanni.features.items.ItemStars;
import at.hannibal2.skyhanni.features.items.RngMeterInventory;
import at.hannibal2.skyhanni.features.items.abilitycooldown.ItemAbilityCooldown;
import at.hannibal2.skyhanni.features.minion.MinionFeatures;
-import at.hannibal2.skyhanni.features.nether.ashfang.AshfangBlazingSouls;
-import at.hannibal2.skyhanni.features.nether.ashfang.AshfangFreezeCooldown;
-import at.hannibal2.skyhanni.features.nether.ashfang.AshfangGravityOrbs;
-import at.hannibal2.skyhanni.features.nether.ashfang.AshfangNextResetCooldown;
+import at.hannibal2.skyhanni.features.nether.ashfang.*;
import at.hannibal2.skyhanni.test.LorenzTest;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
@@ -91,6 +88,7 @@ public class SkyHanniMod {
registerEvent(new SummoningSoulsName());
registerEvent(new AshfangGravityOrbs());
registerEvent(new AshfangBlazingSouls());
+ registerEvent(new AshfangHighlightBlazes());
registerEvent(new ItemStars());
registerEvent(new MinionFeatures());
registerEvent(new RealTime());
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Ashfang.java b/src/main/java/at/hannibal2/skyhanni/config/features/Ashfang.java
index bf3d68f52..cbed42513 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Ashfang.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Ashfang.java
@@ -54,4 +54,9 @@ public class Ashfang {
)
@ConfigEditorColour
public String blazingSoulsColor = "0:245:85:255:85";
+
+ @Expose
+ @ConfigOption(name = "Ashfang Highlight Blazes", desc = "Highlight the different blazes in their respected color")
+ @ConfigEditorBoolean
+ public boolean highlightBlazes = false;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt
new file mode 100644
index 000000000..39d36643d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt
@@ -0,0 +1,5 @@
+package at.hannibal2.skyhanni.events
+
+import net.minecraft.entity.EntityLivingBase
+
+class RenderMobColoredEvent(val entity: EntityLivingBase, var color: Int) : LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtTimeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtTimeEvent.kt
new file mode 100644
index 000000000..ea644e680
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtTimeEvent.kt
@@ -0,0 +1,8 @@
+package at.hannibal2.skyhanni.events
+
+import net.minecraft.entity.EntityLivingBase
+import java.awt.Color
+
+class ResetEntityHurtTimeEvent(val entity: EntityLivingBase, var shouldReset: Boolean) : LorenzEvent()
+
+fun Color.withAlpha(alpha: Int): Int = (alpha.coerceIn(0, 255) shl 24) or (this.rgb and 0x00ffffff) \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt
index 877db7e6a..74cf7847b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt
@@ -2,6 +2,9 @@ package at.hannibal2.skyhanni.features
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.RenderMobColoredEvent
+import at.hannibal2.skyhanni.events.ResetEntityHurtTimeEvent
+import at.hannibal2.skyhanni.events.withAlpha
import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
@@ -15,40 +18,12 @@ import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
-import java.awt.Color
import java.util.regex.Pattern
class SummoningMobManager {
- companion object {
-
- @JvmStatic
- fun <T> setColorMultiplier(
- entity: T,
- lightBrightness: Float,
- partialTickTime: Float,
- cir: CallbackInfoReturnable<Int>,
- ) {
- if (SkyHanniMod.feature.abilities.summoningMobColored) {
- if (entity is EntityLiving && entity in summoningMobs.keys) {
- cir.returnValue = LorenzColor.GREEN.toColor().withAlpha(127)
- }
- }
- }
-
- @JvmStatic
- fun replaceHurtTime(entity: EntityLivingBase): Int {
- return if (SkyHanniMod.feature.abilities.summoningMobColored
- && entity in summoningMobs.keys
- ) 0 else entity.hurtTime
- }
-
- fun Color.withAlpha(alpha: Int): Int = (alpha.coerceIn(0, 255) shl 24) or (this.rgb and 0x00ffffff)
-
- private val summoningMobs = mutableMapOf<EntityLiving, SummoningMob>()
- }
+ private val summoningMobs = mutableMapOf<EntityLiving, SummoningMob>()
private val summoningMobNametags = mutableListOf<EntityArmorStand>()
private var summoningsSpawned = 0
private var searchArmorStands = false
@@ -174,7 +149,7 @@ class SummoningMobManager {
}
@SubscribeEvent
- fun renderOverlay(event: WorldEvent.Load) {
+ fun onWorldChange(event: WorldEvent.Load) {
despawned()
}
@@ -191,6 +166,24 @@ class SummoningMobManager {
event.isCanceled = entity in summoningMobNametags
}
+ @SubscribeEvent
+ fun onRenderMobColored(event: RenderMobColoredEvent) {
+ if (SkyHanniMod.feature.abilities.summoningMobColored) {
+ val entity = event.entity
+ if (entity is EntityLiving && entity in summoningMobs.keys) {
+ event.color = LorenzColor.GREEN.toColor().withAlpha(127)
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onResetEntityHurtTime(event: ResetEntityHurtTimeEvent) {
+ val entity = event.entity
+ if (SkyHanniMod.feature.abilities.summoningMobColored && entity in summoningMobs.keys) {
+ event.shouldReset = true
+ }
+ }
+
private fun despawned() {
summoningMobs.clear()
summoningMobNametags.clear()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHighlightBlazes.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHighlightBlazes.kt
new file mode 100644
index 000000000..274f0b3c9
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHighlightBlazes.kt
@@ -0,0 +1,85 @@
+package at.hannibal2.skyhanni.features.nether.ashfang
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.RenderMobColoredEvent
+import at.hannibal2.skyhanni.events.ResetEntityHurtTimeEvent
+import at.hannibal2.skyhanni.events.withAlpha
+import at.hannibal2.skyhanni.test.LorenzTest
+import at.hannibal2.skyhanni.utils.EntityUtils.getAllNameTagsWith
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import net.minecraft.client.Minecraft
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.entity.monster.EntityBlaze
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
+
+class AshfangHighlightBlazes {
+
+ private val blazes = mutableMapOf<EntityBlaze, LorenzColor>()
+
+ var nearAshfang = false
+ var tick = 0
+
+ @SubscribeEvent
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (!isEnabled()) return
+
+ if (tick++ % 20 == 0) {
+ checkNearAshfang()
+ } else {
+ return
+ }
+
+ if (nearAshfang) {
+ for (entity in Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityBlaze>()
+ .filter { it !in blazes.keys }) {
+ val list = entity.getAllNameTagsWith(2, "Ashfang")
+ if (list.size == 1) {
+ val armorStand = list[0]
+ if (armorStand.name.contains("Ashfang Follower")) {
+ blazes[entity] = LorenzColor.DARK_GRAY
+ } else if (armorStand.name.contains("Ashfang Underling")) {
+ blazes[entity] = LorenzColor.RED
+ } else if (armorStand.name.contains("Ashfang Acolyte")) {
+ blazes[entity] = LorenzColor.BLUE
+ }
+ } else if (list.size > 1) {
+ println("found " + list.size + " name tags")
+ }
+ }
+ }
+
+ }
+
+ private fun checkNearAshfang() {
+ nearAshfang = Minecraft.getMinecraft().theWorld.loadedEntityList
+ .any { it is EntityArmorStand && it.name.contains("Ashfang") }
+ }
+
+ @SubscribeEvent
+ fun onRenderMobColored(event: RenderMobColoredEvent) {
+ if (!isEnabled()) return
+ val entity = event.entity
+ event.color = blazes[entity]?.toColor()?.withAlpha(LorenzTest.a.toInt()) ?: 0
+ }
+
+ @SubscribeEvent
+ fun onResetEntityHurtTime(event: ResetEntityHurtTimeEvent) {
+ if (!isEnabled()) return
+ val entity = event.entity
+ if (entity in blazes) {
+ event.shouldReset = true
+ }
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ blazes.clear()
+ }
+
+ private fun isEnabled(): Boolean {
+ return LorenzUtils.inSkyblock && SkyHanniMod.feature.ashfang.highlightBlazes
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java
index 7ac89c711..98eb386fa 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.mixins.transformers.renderer;
-import at.hannibal2.skyhanni.features.SummoningMobManager;
+import at.hannibal2.skyhanni.events.RenderMobColoredEvent;
+import at.hannibal2.skyhanni.events.ResetEntityHurtTimeEvent;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
@@ -20,11 +21,15 @@ public abstract class MixinRendererLivingEntity<T extends EntityLivingBase> exte
@Inject(method = "getColorMultiplier", at = @At("HEAD"), cancellable = true)
private void setColorMultiplier(T entity, float lightBrightness, float partialTickTime, CallbackInfoReturnable<Integer> cir) {
- SummoningMobManager.setColorMultiplier(entity, lightBrightness, partialTickTime, cir);
+ RenderMobColoredEvent event = new RenderMobColoredEvent(entity, 0);
+ event.postAndCatch();
+ cir.setReturnValue(event.getColor());
}
@Redirect(method = "setBrightness", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/EntityLivingBase;hurtTime:I", opcode = Opcodes.GETFIELD))
- private int changeHurtTime(EntityLivingBase instance) {
- return SummoningMobManager.replaceHurtTime(instance);
+ private int changeHurtTime(EntityLivingBase entity) {
+ ResetEntityHurtTimeEvent event = new ResetEntityHurtTimeEvent(entity, false);
+ event.postAndCatch();
+ return event.getShouldReset() ? 0 : entity.hurtTime;
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
index 143ba4ca1..b95e78a15 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
@@ -16,13 +16,40 @@ object EntityUtils {
return getNameTagWith(y, contains, debugRightEntity, inaccuracy, debugWrongEntity) != null
}
- fun EntityLiving.getNameTagWith(
+ fun EntityLiving.getAllNameTagsWith(
y: Int,
contains: String,
debugRightEntity: Boolean = false,
inaccuracy: Double = 1.6,
debugWrongEntity: Boolean = false,
- ): EntityArmorStand? {
+ ): List<EntityArmorStand> {
+ val center = getLorenzVec().add(0, y, 0)
+ val a = center.add(-inaccuracy, -inaccuracy - 3, -inaccuracy).toBlocPos()
+ val b = center.add(inaccuracy, inaccuracy + 3, inaccuracy).toBlocPos()
+ val alignedBB = AxisAlignedBB(a, b)
+ val clazz = EntityArmorStand::class.java
+ val found = worldObj.getEntitiesWithinAABB(clazz, alignedBB)
+ return found.filter {
+ val result = it.name.contains(contains)
+ if (debugWrongEntity && !result) {
+ println("wrong entity in aabb: '" + it.name + "'")
+ }
+ if (debugRightEntity && result) {
+ println("mob: " + center.printWithAccuracy(2))
+ println("nametag: " + it.getLorenzVec().printWithAccuracy(2))
+ println("accuracy: " + it.getLorenzVec().subtract(center).printWithAccuracy(3))
+ }
+ result
+ }
+ }
+
+ fun EntityLiving.getNameTagWith(
+ y: Int,
+ contains: String,
+ debugRightEntity: Boolean = false,
+ inaccuracy: Double = 1.6,
+ debugWrongEntity: Boolean = false,
+ ): EntityArmorStand? {
val center = getLorenzVec().add(0, y, 0)
val a = center.add(-inaccuracy, -inaccuracy - 3, -inaccuracy).toBlocPos()
val b = center.add(inaccuracy, inaccuracy + 3, inaccuracy).toBlocPos()