diff options
Diffstat (limited to 'src')
7 files changed, 150 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java index c66a23f08..c6aac8bbe 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DevConfig.java @@ -77,6 +77,28 @@ public class DevConfig { public boolean fancyContributors = true; @Expose + @ConfigOption( + name = "Flip Contributors", + desc = "Make SkyHanni contributors appear upside down in the world.") + @ConfigEditorBoolean + public boolean flipContributors = true; + + @Expose + @ConfigOption( + name = "Spin Contributors", + desc = "Make SkyHanni contributors spin around when you are looking at them. " + + "§eRequires 'Flip Contributors' to be enabled.") + @ConfigEditorBoolean + public boolean rotateContributors = false; + + @Expose + @ConfigOption( + name = "SBA Contributors", + desc = "Mark SBA Contributors the same way as SkyHanni contributors.") + @ConfigEditorBoolean + public boolean fancySbaContributors = false; + + @Expose @Category(name = "Minecraft Console", desc = "Minecraft Console Settings") public MinecraftConsoleConfig minecraftConsoles = new MinecraftConsoleConfig(); diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ContributorsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ContributorsJson.kt index 7857da85a..b82e0dc4e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ContributorsJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/ContributorsJson.kt @@ -1,12 +1,14 @@ package at.hannibal2.skyhanni.data.jsonobjects.repo import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName data class ContributorsJson( - @Expose val contributors: Map<String, ContributorJsonEntry> + @Expose val contributors: Map<String, ContributorJsonEntry>, ) data class ContributorJsonEntry( @Expose val suffix: String = "§c:O", - @Expose val spinny: Boolean = false + @Expose val spinny: Boolean = false, + @Expose @SerializedName("external_mod") val externalMod: String? = null, ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt index 16d1088c8..8fff1d56a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ContributorManager.kt @@ -1,11 +1,13 @@ package at.hannibal2.skyhanni.features.misc +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.jsonobjects.repo.ContributorJsonEntry import at.hannibal2.skyhanni.data.jsonobjects.repo.ContributorsJson import at.hannibal2.skyhanni.events.RepositoryReloadEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object ContributorManager { + private val config get() = SkyHanniMod.feature.dev private var contributors: Map<String, ContributorJsonEntry> = emptyMap() @@ -14,11 +16,24 @@ object ContributorManager { contributors = event.getConstant<ContributorsJson>("Contributors").contributors.mapKeys { it.key.lowercase() } } - fun getTabListSuffix(username: String): String? { - return contributors[username.lowercase()]?.suffix - } + fun getTabListSuffix(username: String): String? = getContributor(username)?.suffix + + fun canSpin(username: String): Boolean = getContributor(username)?.spinny ?: false + + private fun getContributor(username: String) = + contributors[username.lowercase()]?.let { it.takeIf { it.isAllowed() } } + + private fun ContributorJsonEntry.isAllowed(): Boolean { + if (!config.fancyContributors) return false + return when (externalMod) { + // normal SkyHanni contributor + null -> true + + // TODO add other mod's devs, e.g skytils + + "SBA" -> config.fancySbaContributors - fun canSpin(username: String): Boolean { - return contributors[username.lowercase()]?.spinny ?: false + else -> false + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt index dd3d7a804..76a5decd8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt @@ -197,10 +197,8 @@ object AdvancedPlayerList { if (config.markSpecialPersons) { suffix += " ${getSocialIcon(data.name).icon()}" } - if (SkyHanniMod.feature.dev.fancyContributors) { - ContributorManager.getTabListSuffix(data.name)?.let { - suffix += " $it" - } + ContributorManager.getTabListSuffix(data.name)?.let { + suffix += " $it" } if (IslandType.CRIMSON_ISLE.isInIsland() && !config.hideFactions) { diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RendererLivingEntityHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RendererLivingEntityHook.kt index 8b724037a..784875f56 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RendererLivingEntityHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RendererLivingEntityHook.kt @@ -1,10 +1,17 @@ package at.hannibal2.skyhanni.mixins.hooks +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.features.misc.ContributorManager import at.hannibal2.skyhanni.utils.EntityOutlineRenderer +import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.entity.player.EnumPlayerModelParts +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable class RendererLivingEntityHook { + private val config get() = SkyHanniMod.feature.dev fun setOutlineColor(red: Float, green: Float, blue: Float, alpha: Float, entity: EntityLivingBase) { val color = EntityOutlineRenderer.getCustomOutlineColor(entity) @@ -18,4 +25,41 @@ class RendererLivingEntityHook { GlStateManager.color(red, green, blue, alpha) } } + + fun isWearing(entityPlayer: EntityPlayer, parts: EnumPlayerModelParts?): Boolean { + if (!LorenzUtils.inSkyBlock) return entityPlayer.isWearing(parts) + return isCoolPerson(entityPlayer.name) || entityPlayer.isWearing(parts) + } + + fun <T> rotateCorpse(displayName: String, bat: T): Boolean { + if (isCoolPerson(displayName)) { + GlStateManager.rotate(getRotation(bat).toFloat(), 0f, 1f, 0f) + } + return isCoolPerson(displayName) + } + + fun onIsWearing(entityPlayer: EntityPlayer, cir: CallbackInfoReturnable<Boolean>) { + if (!isCoolPerson(entityPlayer.name)) return + GlStateManager.rotate(getRotation(entityPlayer).toFloat(), 0f, 1f, 0f) + cir.returnValue = true + } + + fun onEquals(displayName: String, cir: CallbackInfoReturnable<Boolean>) { + if (isCoolPerson(displayName)) { + cir.returnValue = true + } + } + + private fun isCoolPerson(userName: String?): Boolean { + if (!LorenzUtils.inSkyBlock) return false + if (!config.flipContributors && !LorenzUtils.isAprilFoolsDay) return false + val name = userName ?: return false + return ContributorManager.canSpin(name) + } + + private fun <T> getRotation(entity: T): Int { + if (!config.rotateContributors) return 0 + if (entity !is EntityPlayer) return 0 + return (entity.ticksExisted % 90) * 4 + } } diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinContributorRendererEntityLiving.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinContributorRendererEntityLiving.java new file mode 100644 index 000000000..15fafa822 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinContributorRendererEntityLiving.java @@ -0,0 +1,28 @@ +package at.hannibal2.skyhanni.mixins.transformers.renderer; + +import at.hannibal2.skyhanni.mixins.hooks.RendererLivingEntityHook; +import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EnumPlayerModelParts; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(value = RendererLivingEntity.class, priority = 500) +public class MixinContributorRendererEntityLiving<T extends EntityLivingBase> { + + @Unique + private final RendererLivingEntityHook skyHanni$hook = new RendererLivingEntityHook(); + + @Redirect(method = "rotateCorpse", at = @At(value = "INVOKE", target = "Ljava/lang/String;equals(Ljava/lang/Object;)Z", ordinal = 0)) + private boolean rotateCorpse(String displayName, Object v2, T bat, float p_77043_2_, float p_77043_3_, float partialTicks) { + return skyHanni$hook.rotateCorpse(displayName, bat); + } + + @Redirect(method = "rotateCorpse", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayer;isWearing(Lnet/minecraft/entity/player/EnumPlayerModelParts;)Z")) + private boolean rotateCorpse(EntityPlayer bat, EnumPlayerModelParts p_175148_1_) { + return skyHanni$hook.isWearing(bat, EnumPlayerModelParts.CAPE); + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntityHookSBA.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntityHookSBA.java new file mode 100644 index 000000000..1d54872f7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntityHookSBA.java @@ -0,0 +1,30 @@ +package at.hannibal2.skyhanni.mixins.transformers.renderer; + +import at.hannibal2.skyhanni.mixins.hooks.RendererLivingEntityHook; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EnumPlayerModelParts; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +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.CallbackInfoReturnable; + +@Pseudo +@Mixin(targets = "codes/biscuit/skyblockaddons/asm/hooks/RendererLivingEntityHook") +public class MixinRendererLivingEntityHookSBA<T extends EntityLivingBase> { + + @Unique + private static final RendererLivingEntityHook skyHanni$hook = new RendererLivingEntityHook(); + + @Inject(method = "equals", at = @At("HEAD"), cancellable = true, remap = false) + private static void onEquals(String displayName, Object otherString, CallbackInfoReturnable<Boolean> cir) { + skyHanni$hook.onEquals(displayName, cir); + } + + @Inject(method = "isWearing", at = @At("HEAD"), cancellable = true, remap = false) + private static void onIsWearing(EntityPlayer entityPlayer, EnumPlayerModelParts p_175148_1_, CallbackInfoReturnable<Boolean> cir) { + skyHanni$hook.onIsWearing(entityPlayer, cir); + } +} |