added a new command (WIP) and found a bug (see TODO's)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.bytedice.bde_particles
|
||||
|
||||
import com.bytedice.bde_particles.commands.GiveParticleEmitter
|
||||
import com.bytedice.bde_particles.commands.MakeEmitter2
|
||||
import com.bytedice.bde_particles.commands.ManageEmitters
|
||||
import com.bytedice.bde_particles.items.getToolDetails
|
||||
import com.bytedice.bde_particles.math.raycastFromPlayer
|
||||
import com.bytedice.bde_particles.particle.*
|
||||
@@ -47,6 +49,7 @@ class Bde_particles : ModInitializer {
|
||||
|
||||
CommandRegistrationCallback.EVENT.register { dispatcher, registryAccess, _ ->
|
||||
GiveParticleEmitter.register(dispatcher, registryAccess)
|
||||
ManageEmitters .register(dispatcher)
|
||||
}
|
||||
|
||||
UseItemCallback.EVENT.register(UseItemCallback { player: PlayerEntity, world: World, hand: Hand ->
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.bytedice.bde_particles.commands
|
||||
|
||||
import com.bytedice.bde_particles.particle.particleIdRegister
|
||||
import com.mojang.brigadier.Command
|
||||
import com.mojang.brigadier.CommandDispatcher
|
||||
import com.mojang.brigadier.arguments.StringArgumentType
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder
|
||||
import net.minecraft.server.command.CommandManager
|
||||
import net.minecraft.server.command.ServerCommandSource
|
||||
import net.minecraft.text.Text
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
|
||||
// ManageEmitters
|
||||
// <create / config>
|
||||
// create
|
||||
// [emitter id]
|
||||
// [preset emitter id] or DEFAULT
|
||||
// output -> register new emitter with a preset
|
||||
// config
|
||||
// [emitter id]
|
||||
// [particle index]
|
||||
// [param key]
|
||||
// [new param value]
|
||||
// output -> update the selected parameter of the selected particle id to the new value
|
||||
|
||||
object ManageEmitters {
|
||||
fun register(dispatcher: CommandDispatcher<ServerCommandSource>) {
|
||||
val command = CommandManager.literal("ManageEmitters")
|
||||
.requires { source -> source.hasPermissionLevel(4) }
|
||||
|
||||
val allParticleIds = particleIdRegister.keys
|
||||
|
||||
val particleIdArg = CommandManager.argument("Particle ID", StringArgumentType.string())
|
||||
.suggests { _, builder ->
|
||||
val suggestionsBuilder = SuggestionsBuilder(builder.remaining, 0)
|
||||
allParticleIds.forEach { key ->
|
||||
suggestionsBuilder.suggest(key)
|
||||
}
|
||||
CompletableFuture.completedFuture(suggestionsBuilder.build())
|
||||
}
|
||||
|
||||
dispatcher.register(
|
||||
command.then(
|
||||
particleIdArg.executes { context ->
|
||||
val particleId = StringArgumentType.getString(context, "Particle ID")
|
||||
|
||||
val feedback = Text.literal("you chose Particle ID \"$particleId\"")
|
||||
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ class ParticleEmitter(private val emitterPos: Vec3d, private val emitterWorld: S
|
||||
|
||||
|
||||
private fun count() {
|
||||
// TODO: this is broken or something, no particles are spawning
|
||||
// this is the only section I have comments
|
||||
// because im so damn good at cooking spaghetti
|
||||
|
||||
|
||||
@@ -11,8 +11,19 @@ fun returnParticleFunction(id: String) : ParticleEmitterParams? {
|
||||
}
|
||||
|
||||
|
||||
fun addToParticleRegister(id: String, params: ParticleEmitterParams) {
|
||||
particleIdRegister[id] = params
|
||||
fun addToParticleRegister(id: String, params: ParticleEmitterParams) : String {
|
||||
if (!particleIdRegister.containsKey(id)) {
|
||||
particleIdRegister[id] = params
|
||||
|
||||
val msg = "Successfully added particle id \"$id\" to register"
|
||||
println(msg)
|
||||
return msg
|
||||
}
|
||||
else {
|
||||
val msg = "Particle id \"$id\" is already registered, please choose another id!"
|
||||
println(msg)
|
||||
return msg
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user