diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | FEATURES.md | 1 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java | 6 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt | 40 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java | 30 | ||||
-rw-r--r-- | src/main/resources/mixins.skyhanni.json | 3 |
6 files changed, 73 insertions, 8 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ffb2a8e59..03bb309cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Added hiding damage splashes while inside the boss room (replacing a broken feature from Skytils) - Added Summoning Mob Display (Show the health of your spawned summoning mobs listed in an extra GUI element and hiding the corresponding spawning/despawning chat messages) - Added option to hide the nametag of your spawned summoning mobs +- Added option to mark the own summoning mobs in green ### Minor Changes - Optimizing the highlight block size for minions, blazing souls and gravity orbs diff --git a/FEATURES.md b/FEATURES.md index 2523afd71..6964f8ff9 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -40,6 +40,7 @@ - Ashfang Blazing Souls display - Summoning mob display (Show the health of your spawned summoning mobs listed in an extra GUI element and hiding the corresponding spawning/despawning chat messages) - Option to hide the nametag of your spawned summoning mobs +- Option to mark the own summoning mobs in green ## Minion - A display that shows the last time the hopper inside a minion has been emptied diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java b/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java index 6a6995b23..b9a69ed8c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Abilities.java @@ -38,4 +38,10 @@ public class Abilities { @ConfigEditorBoolean @ConfigAccordionId(id = 0) public boolean summoningMobHideNametag = false; + + @Expose + @ConfigOption(name = "Summoning Mob Color", desc = "Marks own summoning mobs green") + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean summoningMobColored = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt index 5b31248d7..877db7e6a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/SummoningMobManager.kt @@ -2,12 +2,9 @@ package at.hannibal2.skyhanni.features import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.utils.LocationUtils -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings -import at.hannibal2.skyhanni.utils.getLorenzVec import net.minecraft.client.Minecraft import net.minecraft.entity.EntityLiving import net.minecraft.entity.EntityLivingBase @@ -18,11 +15,40 @@ 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 { - private val summoningMobs = mutableMapOf<EntityLiving, SummoningMob>() + 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 summoningMobNametags = mutableListOf<EntityArmorStand>() private var summoningsSpawned = 0 private var searchArmorStands = false @@ -95,7 +121,7 @@ class SummoningMobManager { it is EntityLiving && it !in summoningMobs.keys && it.getLorenzVec().distance(playerLocation) < 3 } .forEach { - if (it.ticksExisted == 0) { + if (it.ticksExisted < 2) { summoningMobs[it as EntityLiving] = SummoningMob(System.currentTimeMillis(), name = "Mob") updateData() if (summoningMobs.size == summoningsSpawned) { @@ -117,7 +143,7 @@ class SummoningMobManager { val name = summoningMob.name if (currentHealth == 0) { summoningMobs.remove(entityLiving) - LorenzUtils.chat("§e[SkyHanni] your Summoning Mob just §cdied!") + LorenzUtils.chat("§e[SkyHanni] Your Summoning Mob just §cdied!") continue } 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 new file mode 100644 index 000000000..7ac89c711 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java @@ -0,0 +1,30 @@ +package at.hannibal2.skyhanni.mixins.transformers.renderer; + +import at.hannibal2.skyhanni.features.SummoningMobManager; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.entity.EntityLivingBase; +import org.objectweb.asm.Opcodes; +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.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(RendererLivingEntity.class) +public abstract class MixinRendererLivingEntity<T extends EntityLivingBase> extends Render<T> { + protected MixinRendererLivingEntity(RenderManager renderManager) { + super(renderManager); + } + + @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); + } + + @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); + } +}
\ No newline at end of file diff --git a/src/main/resources/mixins.skyhanni.json b/src/main/resources/mixins.skyhanni.json index 44d3e1e96..1c1feff06 100644 --- a/src/main/resources/mixins.skyhanni.json +++ b/src/main/resources/mixins.skyhanni.json @@ -11,6 +11,7 @@ "gui.MixinGuiContainer", "gui.inventory.GuiEditSignMixin", "tileentity.TileEntitySignMixin", - "renderer.MixinBlockRendererDispatcher" + "renderer.MixinBlockRendererDispatcher", + "renderer.MixinRendererLivingEntity" ] } |