Skip to content

Commit

Permalink
Add basic groundwork for Particle Action (unstable) and Visit Request…
Browse files Browse the repository at this point in the history
… Action.
  • Loading branch information
ixnoahlive committed Jun 7, 2024
1 parent 9a4d327 commit b6159fb
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/kotlin/live/ixnoah/tapactions/TapActions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package live.ixnoah.tapactions

import live.ixnoah.tapactions.actions.GeneralActions
import live.ixnoah.tapactions.actions.HudActions
import live.ixnoah.tapactions.actions.WorldActions
import live.ixnoah.tapactions.commands.CreateActionCommand
import live.ixnoah.tapactions.events.ClientTick
import live.ixnoah.tapactions.events.WorldLoad
Expand Down Expand Up @@ -35,6 +36,7 @@ class TapActions {

// Deploy actions
GeneralActions.deploy()
WorldActions.deploy()
HudActions.deploy()
}
}
20 changes: 19 additions & 1 deletion src/main/kotlin/live/ixnoah/tapactions/actions/GeneralActions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package live.ixnoah.tapactions.actions
import CommandQueue
import live.ixnoah.tapactions.ActionManager
import live.ixnoah.tapactions.wrappers.Scoreboard
import net.minecraft.client.Minecraft
import net.minecraft.event.ClickEvent
import net.minecraft.event.HoverEvent
import net.minecraft.util.ChatComponentStyle
import net.minecraft.util.ChatComponentText
import net.minecraft.util.ChatStyle

object GeneralActions {
private val nameRegex = Regex("^[0-9A-z '\"!@#\$%^*?]{0,20}\$")
Expand Down Expand Up @@ -32,8 +38,20 @@ object GeneralActions {
}
}

private val actionVisitHouse = { params: MutableMap<String, String> ->
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
.setChatStyle(ChatStyle().setChatHoverEvent(
HoverEvent(HoverEvent.Action.SHOW_TEXT, ChatComponentText("§7/visit ${params["player"]} ${params["house"]}"))
).setChatClickEvent(ClickEvent(ClickEvent.Action.RUN_COMMAND, "/visit ${params["player"]} ${params["house"]}"))
)
)
}

fun deploy() {
ActionManager.registerAction("tap:identity", actionIdentity)
ActionManager.registerAction("tap:visibility", actionVisibility)
ActionManager.registerAction("tap:visibility", actionVisibility, mutableListOf("max"))
ActionManager.registerAction("tap:visit", actionVisitHouse, mutableListOf("player", "house"))
}
}
33 changes: 33 additions & 0 deletions src/main/kotlin/live/ixnoah/tapactions/actions/WorldActions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package live.ixnoah.tapactions.actions

import live.ixnoah.tapactions.ActionManager
import net.minecraft.client.Minecraft
import net.minecraft.util.EnumParticleTypes

object WorldActions {
private val actionParticle = { params: MutableMap<String, String> ->
val particleType = params["particle"]?.let { EnumParticleTypes.valueOf(it) }

if (particleType !== null) {
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,
)
}
}

fun deploy() {
ActionManager.registerAction(
"tap:particle",
actionParticle,
mutableListOf(
"particle",
"x", "y", "z",
))
}
}

0 comments on commit b6159fb

Please sign in to comment.