diff --git a/build.gradle.kts b/build.gradle.kts index 7b72b87..66a79ba 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { id("gg.essential.loom") version "0.10.0.+" id("dev.architectury.architectury-pack200") version "0.1.3" id("com.github.johnrengelman.shadow") version "8.1.1" - kotlin("jvm") version "1.8.21" + kotlin("jvm") version "2.0.0" } //Constants: diff --git a/src/main/kotlin/live/ixnoah/tapactions/ActionManager.kt b/src/main/kotlin/live/ixnoah/tapactions/ActionManager.kt index 6b046db..e41b598 100644 --- a/src/main/kotlin/live/ixnoah/tapactions/ActionManager.kt +++ b/src/main/kotlin/live/ixnoah/tapactions/ActionManager.kt @@ -24,7 +24,7 @@ object ActionManager { val definedParams = params?.keys val missingParams = mutableListOf() - if (definedParams !== null && action.paramsRequired?.isNotEmpty() == true) { + if (definedParams != null && action.paramsRequired?.isNotEmpty() == true) { action.paramsRequired.forEach { paramName -> if (!definedParams.contains(paramName)) missingParams.add(paramName) } diff --git a/src/main/kotlin/live/ixnoah/tapactions/actions/GeneralActions.kt b/src/main/kotlin/live/ixnoah/tapactions/actions/GeneralActions.kt index 16df7d5..4020242 100644 --- a/src/main/kotlin/live/ixnoah/tapactions/actions/GeneralActions.kt +++ b/src/main/kotlin/live/ixnoah/tapactions/actions/GeneralActions.kt @@ -15,7 +15,7 @@ object GeneralActions { var hasStatedIdentity = false /** This can be used to show the identity of a house, like name, links & description! */ - private val actionIdentity = { params : MutableMap -> + private fun actionIdentity( params : MutableMap) { if (!hasStatedIdentity) { hasStatedIdentity = true val paramName = params["name"] ?: "Housing" @@ -24,21 +24,21 @@ object GeneralActions { Scoreboard.setTitle("§e§l" + paramName.uppercase()) } - if (params["run"] !== null) { + if (params["run"] != null) { CommandQueue.pushCommand("house:${params["run"]}") } } } - private val actionVisibility = { params : MutableMap -> + private fun actionVisibility ( params : MutableMap ) { val paramVis : Int? = params["max"]?.toIntOrNull() - if (paramVis !== null) { + if (paramVis != null) { CommandQueue.pushCommand("visibility $paramVis") } } - private val actionVisitHouse = { params: MutableMap -> + private fun actionVisitHouse( params: MutableMap ) { Minecraft.getMinecraft().thePlayer.addChatMessage( ChatComponentText("§eThis house wants you to visit §b${params["house"]}§e! Click to visit!") // This is fucking awful but Minecraft devs has forced my hand @@ -50,8 +50,8 @@ object GeneralActions { } fun deploy() { - ActionManager.registerAction("tap:identity", actionIdentity) - ActionManager.registerAction("tap:visibility", actionVisibility, mutableListOf("max")) - ActionManager.registerAction("tap:visit", actionVisitHouse, mutableListOf("player", "house")) + ActionManager.registerAction("tap:identity", ::actionIdentity) + ActionManager.registerAction("tap:visibility", ::actionVisibility, mutableListOf("max")) + ActionManager.registerAction("tap:visit", ::actionVisitHouse, mutableListOf("player", "house")) } } \ No newline at end of file diff --git a/src/main/kotlin/live/ixnoah/tapactions/actions/HudActions.kt b/src/main/kotlin/live/ixnoah/tapactions/actions/HudActions.kt index 9f61f69..224987d 100644 --- a/src/main/kotlin/live/ixnoah/tapactions/actions/HudActions.kt +++ b/src/main/kotlin/live/ixnoah/tapactions/actions/HudActions.kt @@ -4,27 +4,29 @@ import live.ixnoah.tapactions.ActionManager import net.minecraft.entity.boss.BossStatus object HudActions { - private val actionBossbar = { params : MutableMap -> + private fun actionBossbar( params : MutableMap) { if (params["no-clear"] == null) { BossStatus.statusBarTime = Int.MAX_VALUE BossStatus.healthScale = 1f BossStatus.bossName = "" } - var max_health = 100 + var maxHealth = 100 - if (params["name"] !== null) BossStatus.bossName = params["name"] - if (params["max_health"]?.toIntOrNull() !== null) max_health = params["max_health"]?.toInt() ?: 100 + if (params["name"] != null) BossStatus.bossName = params["name"] + if (params["max_health"]?.toIntOrNull() != null) maxHealth = params["max_health"]?.toInt() ?: 100 - var healthScale = ( params["health"]?.toInt() ?: 100 ).toFloat() / max_health.toFloat() + var healthScale = ( params["health"]?.toInt() ?: 100 ).toFloat() / maxHealth.toFloat() if (healthScale > 1 || healthScale < 0) healthScale = 1f - BossStatus.healthScale = healthScale + if (params["no-clear"] == null + || params["health"] != null + || params["max_health"] != null) BossStatus.healthScale = healthScale - if (params["duration"]?.toFloatOrNull() !== null) BossStatus.statusBarTime = ((params["duration"]?.toFloat() ?: 1f) * 60).toInt() + if (params["duration"]?.toFloatOrNull() != null) BossStatus.statusBarTime = ((params["duration"]?.toFloat() ?: 1f) * 60).toInt() } fun deploy() { - ActionManager.registerAction("tap:bossbar", actionBossbar) + ActionManager.registerAction("tap:bossbar", ::actionBossbar) } } \ No newline at end of file diff --git a/src/main/kotlin/live/ixnoah/tapactions/actions/WorldActions.kt b/src/main/kotlin/live/ixnoah/tapactions/actions/WorldActions.kt index bfe484a..22cd090 100644 --- a/src/main/kotlin/live/ixnoah/tapactions/actions/WorldActions.kt +++ b/src/main/kotlin/live/ixnoah/tapactions/actions/WorldActions.kt @@ -5,29 +5,30 @@ import net.minecraft.client.Minecraft import net.minecraft.util.EnumParticleTypes object WorldActions { - private val actionParticle = { params: MutableMap -> - val particleType = params["particle"]?.let { EnumParticleTypes.valueOf(it) } + var particlesRendered = 0 + private fun actionParticle(params: MutableMap) { + if (particlesRendered > 100) return + if (EnumParticleTypes.entries.none { it.name == params["type"] }) return - if (particleType !== null) { - Minecraft.getMinecraft().theWorld.spawnParticle( + val particleType = EnumParticleTypes.valueOf(params["type"]!!) + + val xyz = params["pos"]?.split(" ")?.map { item -> item.toDoubleOrNull() } + val pos = mutableMapOf( + "x" to (xyz?.get(0) ?: 0.00), + "y" to (xyz?.get(1) ?: 0.00), + "z" to (xyz?.get(2) ?: 0.00), + ) + + Minecraft.getMinecraft().theWorld.spawnParticle( particleType, - params["x"]?.toDoubleOrNull() ?: 0.00, - params["y"]?.toDoubleOrNull() ?: 0.00, - params["z"]?.toDoubleOrNull() ?: 0.00, - params["ox"]?.toDoubleOrNull() ?: 0.00, - params["oy"]?.toDoubleOrNull() ?: 0.00, - params["oz"]?.toDoubleOrNull() ?: 0.00, - ) - } + pos["x"]!!, pos["y"]!!, pos["z"]!!, + 0.00, 0.00, 0.00 + ) + + particlesRendered++ } fun deploy() { - ActionManager.registerAction( - "tap:particle", - actionParticle, - mutableListOf( - "particle", - "x", "y", "z", - )) + ActionManager.registerAction("tap:particle", ::actionParticle, mutableListOf("type", "pos" )) } } \ No newline at end of file diff --git a/src/main/kotlin/live/ixnoah/tapactions/events/ClientTick.kt b/src/main/kotlin/live/ixnoah/tapactions/events/ClientTick.kt index 614089e..082e234 100644 --- a/src/main/kotlin/live/ixnoah/tapactions/events/ClientTick.kt +++ b/src/main/kotlin/live/ixnoah/tapactions/events/ClientTick.kt @@ -1,6 +1,7 @@ package live.ixnoah.tapactions.events import CommandQueue +import live.ixnoah.tapactions.actions.WorldActions import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent @@ -13,5 +14,6 @@ class ClientTick { tick += 1 CommandQueue.onTick(tick) + WorldActions.particlesRendered = 0 } } \ No newline at end of file diff --git a/src/main/kotlin/live/ixnoah/tapactions/events/WorldLoad.kt b/src/main/kotlin/live/ixnoah/tapactions/events/WorldLoad.kt index a57c0bc..f7514f2 100644 --- a/src/main/kotlin/live/ixnoah/tapactions/events/WorldLoad.kt +++ b/src/main/kotlin/live/ixnoah/tapactions/events/WorldLoad.kt @@ -10,10 +10,11 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class WorldLoad { @SubscribeEvent fun onEvent(event: EntityJoinWorldEvent) { - if (event.entity !== Minecraft.getMinecraft().thePlayer) return + if (event.entity != Minecraft.getMinecraft().thePlayer) return BossStatus.statusBarTime = 0 // clears the bossbar CommandQueue.clearQueue() GeneralActions.hasStatedIdentity = false + } } diff --git a/src/main/kotlin/live/ixnoah/tapactions/misc/TitleHandler.kt b/src/main/kotlin/live/ixnoah/tapactions/misc/TitleHandler.kt index 46da269..c64be68 100644 --- a/src/main/kotlin/live/ixnoah/tapactions/misc/TitleHandler.kt +++ b/src/main/kotlin/live/ixnoah/tapactions/misc/TitleHandler.kt @@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo object TitleHandler { fun handleTitle(packetIn: S45PacketTitle, ci: CallbackInfo) { - if (packetIn.type.toString() !== "TITLE") return + if (packetIn.type.toString() != "TITLE") return var messageContent = packetIn.message.unformattedText if (!messageContent.startsWith("␁")) return diff --git a/src/main/resources/assets/test/test.txt b/src/main/resources/assets/test/test.txt deleted file mode 100644 index ea839e2..0000000 --- a/src/main/resources/assets/test/test.txt +++ /dev/null @@ -1,3 +0,0 @@ -test -from resource pack -