diff options
-rw-r--r-- | build.gradle.kts | 6 | ||||
-rw-r--r-- | settings.gradle.kts | 2 | ||||
-rw-r--r-- | src/main/java/dulkirmod/mixins/MixinItem.java | 20 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/DulkirMod.kt | 11 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/config/DulkirConfig.kt | 18 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/ImpactDisplay.kt | 52 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/ReaperDisplay.kt | 52 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/features/dungeons/ArcherHighlight.kt | 66 |
8 files changed, 179 insertions, 48 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 39f80ce..e67a8fa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jetbrains.kotlin.ir.backend.js.compile plugins { idea @@ -28,6 +29,7 @@ loom { property("asmhelper.verbose", "true") arg("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker") arg("--mixin", "mixins.dulkirmod.json") + arg("--tweakClass", "gg.essential.loader.stage0.EssentialSetupTweaker") } } forge { @@ -70,9 +72,10 @@ dependencies { minecraft("com.mojang:minecraft:1.8.9") mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") + shadowImpl("gg.essential:loader-launchwrapper:1.1.3") // If you don't want mixins, remove these lines - shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") { + compileOnly("org.spongepowered:mixin:0.8.5-SNAPSHOT") { isTransitive = false } annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT:processor") @@ -84,7 +87,6 @@ dependencies { compileOnly("cc.polyfrost:oneconfig-1.8.9-forge:0.2.0-alpha+") // Should not be included in jar // include should be replaced with a configuration that includes this in the jar shadowImpl("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+") // Should be included in jar - } // Configures our shadow/shade configuration, so we can diff --git a/settings.gradle.kts b/settings.gradle.kts index 4e688e6..aba9c52 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,4 +19,4 @@ pluginManagement { } } -rootProject.name = "dulkirmod" +rootProject.name = "DulkirMod" diff --git a/src/main/java/dulkirmod/mixins/MixinItem.java b/src/main/java/dulkirmod/mixins/MixinItem.java index d3cb421..62ae99d 100644 --- a/src/main/java/dulkirmod/mixins/MixinItem.java +++ b/src/main/java/dulkirmod/mixins/MixinItem.java @@ -1,6 +1,9 @@ package dulkirmod.mixins; import dulkirmod.DulkirMod; +import dulkirmod.config.DulkirConfig; +import dulkirmod.features.ImpactDisplay; +import dulkirmod.features.ReaperDisplay; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; @@ -16,4 +19,21 @@ public class MixinItem { if (DulkirMod.Companion.getConfig().getCancelReequip()) ci.setReturnValue(false); } + + @Inject(method = "showDurabilityBar(Lnet/minecraft/item/ItemStack;)Z", at = @At("HEAD"), + cancellable = true, remap = false) + public void shouldShowDur(ItemStack stack, CallbackInfoReturnable<Boolean> cir) { + if (DulkirConfig.INSTANCE.getDisplayReaperCD()) + ReaperDisplay.INSTANCE.shouldDisplay(stack, cir); + if (DulkirConfig.INSTANCE.getDisplayImpactCD()) + ImpactDisplay.INSTANCE.shouldDisplay(stack, cir); + } + @Inject(method = "getDurabilityForDisplay(Lnet/minecraft/item/ItemStack;)D", at = @At("HEAD"), + cancellable = true, remap = false) + public void getItemHealthDisplayVal(ItemStack stack, CallbackInfoReturnable<Double> cir) { + if (DulkirConfig.INSTANCE.getDisplayReaperCD()) + ReaperDisplay.INSTANCE.calcDurability(stack, cir); + if (DulkirConfig.INSTANCE.getDisplayImpactCD()) + ImpactDisplay.INSTANCE.calcDurability(stack, cir); + } } diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt index 88b032a..de89d9e 100644 --- a/src/main/kotlin/dulkirmod/DulkirMod.kt +++ b/src/main/kotlin/dulkirmod/DulkirMod.kt @@ -10,8 +10,6 @@ import dulkirmod.features.rift.IchorHighlight import dulkirmod.features.rift.SteakDisplay import dulkirmod.utils.* import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiScreen import net.minecraft.client.settings.KeyBinding @@ -20,7 +18,6 @@ import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.client.registry.ClientRegistry import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.event.FMLInitializationEvent -import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent import net.minecraftforge.fml.common.event.FMLPreInitializationEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent @@ -28,7 +25,6 @@ import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent import org.lwjgl.input.Keyboard import java.io.File -import java.lang.management.ManagementFactory import kotlin.coroutines.EmptyCoroutineContext @Mod( @@ -89,15 +85,12 @@ class DulkirMod { mcBus.register(IchorHighlight) mcBus.register(SteakDisplay) mcBus.register(ArcherHighlight) + mcBus.register(ReaperDisplay) + mcBus.register(ImpactDisplay) keyBinds.forEach(ClientRegistry::registerKeyBinding) } - @Mod.EventHandler - fun postInit(event: FMLLoadCompleteEvent) = scope.launch(Dispatchers.IO) { - - } - @SubscribeEvent fun onTick(event: ClientTickEvent) { if (DulkirConfig.noReverse3rdPerson && mc.gameSettings.thirdPersonView == 2) diff --git a/src/main/kotlin/dulkirmod/config/DulkirConfig.kt b/src/main/kotlin/dulkirmod/config/DulkirConfig.kt index 858d11f..d8ac14c 100644 --- a/src/main/kotlin/dulkirmod/config/DulkirConfig.kt +++ b/src/main/kotlin/dulkirmod/config/DulkirConfig.kt @@ -79,6 +79,22 @@ object DulkirConfig : Config(Mod("DulkirMod", ModType.SKYBLOCK), "dulkirmod-conf var hideEnchantRune = false @Switch( + name = "Reaper Armor Cooldown Display", + description = "Will show as item durability", + category = "General", + subcategory = "General" + ) + var displayReaperCD = false + + @Switch( + name = "Wither Impact Cooldown Display", + description = "Will show as item durability", + category = "General", + subcategory = "General" + ) + var displayImpactCD = false + + @Switch( name = "Abiphone Do-Not-Disturb", description = "Detects incoming calls and mutes ring audio for like 5 seconds. \nWorks as long as u don't lag particularly hard at the same time you're being called.", category = "General", @@ -834,6 +850,6 @@ object DulkirConfig : Config(Mod("DulkirMod", ModType.SKYBLOCK), "dulkirmod-conf addDependency("persistentAlert", "notifyMaxVisitors") addDependency("secretSoundVolume", "secretClickSounds") addDependency("demoSecretVolume", "secretClickSounds") - addDependency("boxArcherEverywhere", "boxArcher") + addDependency("archerBoxEverywhere", "archerBox") } } diff --git a/src/main/kotlin/dulkirmod/features/ImpactDisplay.kt b/src/main/kotlin/dulkirmod/features/ImpactDisplay.kt new file mode 100644 index 0000000..e1d3f07 --- /dev/null +++ b/src/main/kotlin/dulkirmod/features/ImpactDisplay.kt @@ -0,0 +1,52 @@ +package dulkirmod.features + +import net.minecraft.item.ItemStack +import net.minecraft.nbt.NBTTagCompound +import net.minecraftforge.client.event.sound.PlaySoundEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import kotlin.math.min + +object ImpactDisplay { + + var lastImpact = 0L + + fun shouldDisplay(stack: ItemStack, cir: CallbackInfoReturnable<Boolean>) { + if (!isBlade(stack)) return + cir.returnValue = System.currentTimeMillis() - lastImpact < 5000 + } + + fun calcDurability(stack: ItemStack, cir: CallbackInfoReturnable<Double>) { + if (!isBlade(stack)) return + val time = (System.currentTimeMillis() - lastImpact) / 5000.0 + cir.returnValue = min(1.0, 1.0 - time) + } + + @SubscribeEvent + fun onSound(event: PlaySoundEvent) { + if (event.name != "mob.zombie.remedy") return + if (event.sound.pitch != 0.6984127f) return + if (event.sound.volume != 1.0f) return + lastImpact = System.currentTimeMillis() + } + + @SubscribeEvent + fun onWorldLoad(event: WorldEvent.Load) { + lastImpact = 0L + } + + private fun isBlade(stack: ItemStack): Boolean { + if (stack.hasTagCompound()) { + val tag: NBTTagCompound = stack.tagCompound + if (tag.hasKey("ExtraAttributes", 10) && tag.hasKey("display", 10)) { + val ea: NBTTagCompound = tag.getCompoundTag("ExtraAttributes") + if (ea.hasKey("id", 8)) { + val id = ea.getString("id") + return id matches "(HYPERION|ASTRAEA|SCYLLA|VALKYRIE)".toRegex() + } + } + } + return false + } +}
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/ReaperDisplay.kt b/src/main/kotlin/dulkirmod/features/ReaperDisplay.kt new file mode 100644 index 0000000..3fd743d --- /dev/null +++ b/src/main/kotlin/dulkirmod/features/ReaperDisplay.kt @@ -0,0 +1,52 @@ +package dulkirmod.features + +import net.minecraft.item.ItemStack +import net.minecraft.nbt.NBTTagCompound +import net.minecraftforge.client.event.sound.PlaySoundEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import kotlin.math.min + +object ReaperDisplay { + + var lastReaperUsage = 0L + + fun shouldDisplay(stack: ItemStack, cir: CallbackInfoReturnable<Boolean>) { + if (!isReaper(stack)) return + cir.returnValue = System.currentTimeMillis() - lastReaperUsage < 25000 + } + + fun calcDurability(stack: ItemStack, cir: CallbackInfoReturnable<Double>) { + if (!isReaper(stack)) return + val time = (System.currentTimeMillis() - lastReaperUsage) / 25000.0 + cir.returnValue = min(1.0, 1.0 - time) + } + + @SubscribeEvent + fun onSound(event: PlaySoundEvent) { + if (event.name != "mob.zombie.remedy") return + if (event.sound.pitch != 1.0f) return + if (event.sound.volume != .5f) return + lastReaperUsage = System.currentTimeMillis() + } + + @SubscribeEvent + fun onWorldLoad(event: WorldEvent) { + lastReaperUsage = 0L + } + + private fun isReaper(stack: ItemStack): Boolean { + if (stack.hasTagCompound()) { + val tag: NBTTagCompound = stack.tagCompound + if (tag.hasKey("ExtraAttributes", 10) && tag.hasKey("display", 10)) { + val ea: NBTTagCompound = tag.getCompoundTag("ExtraAttributes") + if (ea.hasKey("id", 8)) { + val id = ea.getString("id") + return id matches "(REAPER_CHESTPLATE)|(REAPER_LEGGINGS)|(REAPER_BOOTS)".toRegex() + } + } + } + return false + } +}
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/features/dungeons/ArcherHighlight.kt b/src/main/kotlin/dulkirmod/features/dungeons/ArcherHighlight.kt index 395d363..68a8659 100644 --- a/src/main/kotlin/dulkirmod/features/dungeons/ArcherHighlight.kt +++ b/src/main/kotlin/dulkirmod/features/dungeons/ArcherHighlight.kt @@ -1,43 +1,39 @@ package dulkirmod.features.dungeons -import com.google.common.eventbus.Subscribe import dulkirmod.DulkirMod.Companion.mc import dulkirmod.config.DulkirConfig import dulkirmod.utils.ScoreBoardUtils import dulkirmod.utils.TabListUtils import dulkirmod.utils.WorldRenderUtils -import ibxm.Player -import net.minecraft.entity.player.EntityPlayer -import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.awt.Color object ArcherHighlight { - -// @SubscribeEvent -// fun onRenderLiving(event: RenderLivingEvent.Pre<*>) { -// if (!DulkirConfig.archerBox) return -// if (TabListUtils.area != "Dungeon") return -// if (!ScoreBoardUtils.isInM7 && !DulkirConfig.archerBoxEverywhere) return -// if (event.entity !is EntityPlayer) return -// val name = event.entity.name ?: return -// if (name != TabListUtils.archerName) return -// if (mc.thePlayer.positionVector.yCoord > 45 && !DulkirConfig.archerBoxEverywhere) return -// if (mc.thePlayer.name == name) return -// val (x, y, z) = WorldRenderUtils.fixRenderPos(event.x, event.y, event.z) -// WorldRenderUtils.drawCustomBox( -// x - .5, -// 1.0, -// y, -// 2.0, -// z - .5, -// 1.0, -// DulkirConfig.archBoxColor.toJavaColor(), -// 3f, -// phase = false -// ) -// } + /**The following code is broken but interesting because with SBA it makes RGB PEOPLE + @SubscribeEvent + fun onRenderLiving(event: RenderLivingEvent.Pre<*>) { + if (!DulkirConfig.archerBox) return + if (TabListUtils.area != "Dungeon") return + if (!ScoreBoardUtils.isInM7 && !DulkirConfig.archerBoxEverywhere) return + if (event.entity !is EntityPlayer) return + val name = event.entity.name ?: return + if (name != TabListUtils.archerName) return + if (mc.thePlayer.positionVector.yCoord > 45 && !DulkirConfig.archerBoxEverywhere) return + if (mc.thePlayer.name == name) return + val (x, y, z) = WorldRenderUtils.fixRenderPos(event.x, event.y, event.z) + WorldRenderUtils.drawCustomBox( + x - .5, + 1.0, + y, + 2.0, + z - .5, + 1.0, + DulkirConfig.archBoxColor.toJavaColor(), + 3f, + phase = false + ) + } + */ @SubscribeEvent fun onRenderWorldLast(event: RenderWorldLastEvent) { @@ -47,12 +43,12 @@ object ArcherHighlight { val players = mc.theWorld.playerEntities.filterNotNull() players.forEach { val name = it.name ?: return@forEach - if (name != TabListUtils.archerName) return - if (mc.thePlayer.positionVector.yCoord > 45 && !DulkirConfig.archerBoxEverywhere) return - if (mc.thePlayer.name == name) return - val x = it.posX - ((it.lastTickPosX - it.posX) * event.partialTicks) - val y = it.posY - ((it.lastTickPosY - it.posY) * event.partialTicks) - val z = it.posZ - ((it.lastTickPosZ - it.posZ) * event.partialTicks) + if (name != TabListUtils.archerName) return@forEach + if (mc.thePlayer.positionVector.yCoord > 45 && !DulkirConfig.archerBoxEverywhere) return@forEach + if (mc.thePlayer.name == name) return@forEach + val x = it.lastTickPosX + ((it.posX - it.lastTickPosX) * event.partialTicks) + val y = it.lastTickPosY + ((it.posY - it.lastTickPosY) * event.partialTicks) + val z = it.lastTickPosZ + ((it.posZ - it.lastTickPosZ) * event.partialTicks) WorldRenderUtils.drawCustomBox( x - .5, 1.0, |