mostly reindents
This commit is contained in:
@@ -34,24 +34,25 @@ object GiveEmitterTool {
|
||||
}
|
||||
|
||||
dispatcher.register(
|
||||
command.then(
|
||||
itemNameArg.then(
|
||||
itemTypeArg.then(
|
||||
emitterIdSuggestion.executes { context ->
|
||||
val name = StringArgumentType.getString(context, "Item Name")
|
||||
val item = ItemStackArgumentType.getItemStackArgument(context, "Item Type")
|
||||
val emitterId = StringArgumentType.getString(context, "Emitter ID")
|
||||
command
|
||||
.then(itemNameArg
|
||||
.then(itemTypeArg
|
||||
.then(emitterIdSuggestion
|
||||
.executes { context ->
|
||||
val name = StringArgumentType.getString(context, "Item Name")
|
||||
val item = ItemStackArgumentType.getItemStackArgument(context, "Item Type")
|
||||
val emitterId = StringArgumentType.getString(context, "Emitter ID")
|
||||
|
||||
val feedback = Text.literal("BPS - You like fancy particles. Don't you?\nBPS - gave particle emitter, bound to ID: \"${emitterId}\".")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(0, 200, 0).rgb)))
|
||||
val feedback = Text.literal("BPS - You like fancy particles. Don't you?\nBPS - gave particle emitter, bound to ID: \"${emitterId}\".")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(0, 200, 0).rgb)))
|
||||
|
||||
context.source.player?.inventory?.insertStack(ParticleEmitterTool.makeData(item.item, name, emitterId))
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
context.source.player?.inventory?.insertStack(ParticleEmitterTool.makeData(item.item, name, emitterId))
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,17 @@ object KillAllEmitters {
|
||||
.requires { source -> source.hasPermissionLevel(4) }
|
||||
|
||||
dispatcher.register(
|
||||
command
|
||||
.executes { context ->
|
||||
for (emitter in ALL_PARTICLE_EMITTERS) {
|
||||
emitter.kill()
|
||||
}
|
||||
|
||||
val feedback = Text.literal("BPS - Killed all living Emitters.")
|
||||
.setStyle(Style.EMPTY.withColor(Color(0, 200, 0).rgb))
|
||||
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
command.executes { context ->
|
||||
for (emitter in ALL_PARTICLE_EMITTERS) {
|
||||
emitter.kill()
|
||||
}
|
||||
|
||||
val feedback = Text.literal("BPS - Killed all living Emitters.")
|
||||
.setStyle(Style.EMPTY.withColor(Color(0, 200, 0).rgb))
|
||||
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.bytedice.bde_particles.commands
|
||||
|
||||
import com.bytedice.bde_particles.InterpolationCurves
|
||||
import com.bytedice.bde_particles.particles.SpawningShape
|
||||
import com.bytedice.bde_particles.particles.updateSingleParam
|
||||
import com.bytedice.bde_particles.particles.*
|
||||
import com.mojang.brigadier.Command
|
||||
import com.mojang.brigadier.arguments.BoolArgumentType
|
||||
import com.mojang.brigadier.arguments.FloatArgumentType
|
||||
@@ -125,195 +124,175 @@ class ArgConfigEmitterKeys {
|
||||
class ArgConfigParticleKeys {
|
||||
fun shape() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("shape")
|
||||
.then(
|
||||
CommandManager.literal("circle")
|
||||
.then(
|
||||
CommandManager.argument("Radius", FloatArgumentType.floatArg())
|
||||
.then(CommandManager.literal("circle")
|
||||
.then(CommandManager.argument("Radius", FloatArgumentType.floatArg())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val radius = FloatArgumentType.getFloat(context, "Radius")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.CIRCLE(radius))
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
)
|
||||
.then(CommandManager.literal("rect")
|
||||
.then(CommandManager.argument("Width", FloatArgumentType.floatArg())
|
||||
.then(CommandManager.argument("Height", FloatArgumentType.floatArg())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val w = FloatArgumentType.getFloat(context, "Width")
|
||||
val h = FloatArgumentType.getFloat(context, "Height")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.RECT(Vector2f(w, h)))
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
.then(CommandManager.literal("cube")
|
||||
.then(CommandManager.argument("X", FloatArgumentType.floatArg())
|
||||
.then(CommandManager.argument("Y", FloatArgumentType.floatArg())
|
||||
.then(CommandManager.argument("Z", FloatArgumentType.floatArg())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val radius = FloatArgumentType.getFloat(context, "Radius")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.Circle(radius))
|
||||
val x = FloatArgumentType.getFloat(context, "X")
|
||||
val y = FloatArgumentType.getFloat(context, "Y")
|
||||
val z = FloatArgumentType.getFloat(context, "Z")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.CUBE(Vector3f(x, y, z)))
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.then(
|
||||
CommandManager.literal("rect")
|
||||
.then(
|
||||
CommandManager.argument("Width", FloatArgumentType.floatArg())
|
||||
.then(
|
||||
CommandManager.argument("Height", FloatArgumentType.floatArg())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val w = FloatArgumentType.getFloat(context, "Width")
|
||||
val h = FloatArgumentType.getFloat(context, "Height")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.Rect(Vector2f(w, h)))
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
.then(
|
||||
CommandManager.literal("cube")
|
||||
.then(
|
||||
CommandManager.argument("X", FloatArgumentType.floatArg())
|
||||
.then(
|
||||
CommandManager.argument("Y", FloatArgumentType.floatArg())
|
||||
.then(
|
||||
CommandManager.argument("Z", FloatArgumentType.floatArg())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val x = FloatArgumentType.getFloat(context, "X")
|
||||
val y = FloatArgumentType.getFloat(context, "Y")
|
||||
val z = FloatArgumentType.getFloat(context, "Z")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.Cube(Vector3f(x, y, z)))
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.then(
|
||||
CommandManager.literal("sphere")
|
||||
.then(
|
||||
CommandManager.argument("Radius", FloatArgumentType.floatArg())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val radius = FloatArgumentType.getFloat(context, "Radius")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.Sphere(radius))
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
.then(CommandManager.literal("sphere")
|
||||
.then(CommandManager.argument("Radius", FloatArgumentType.floatArg())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val radius = FloatArgumentType.getFloat(context, "Radius")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "shape", SpawningShape.SPHERE(radius))
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
fun blockCurve() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("blockCurve")
|
||||
.then(
|
||||
CommandManager.argument("Array (separate by comma)", StringArgumentType.string())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val typeValue = StringArgumentType.getString(context, "Array (separate by comma)")
|
||||
val typeArray = typeValue.split(",").toTypedArray()
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "blockCurve", typeArray)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
.then(CommandManager.argument("Array (separate by comma)", StringArgumentType.string())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val typeValue = StringArgumentType.getString(context, "Array (separate by comma)")
|
||||
val typeArray = typeValue.split(",").toTypedArray()
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "blockCurve", typeArray)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
fun rotRandom() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("rotRandom")
|
||||
.then(
|
||||
argPairVector3f()
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val vectors = x1x2ToPairVector3f(context)
|
||||
.then(argPairVector3f()
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val vectors = x1x2ToPairVector3f(context)
|
||||
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "rotRandom", vectors)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "rotRandom", vectors)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
fun rotVelRandom() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("rotVelRandom")
|
||||
.then(
|
||||
argPairVector3f()
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val vectors = x1x2ToPairVector3f(context)
|
||||
.then(argPairVector3f()
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val vectors = x1x2ToPairVector3f(context)
|
||||
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "rotVelRandom", vectors)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "rotVelRandom", vectors)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
fun sizeRandom() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("sizeRandom")
|
||||
.then(
|
||||
argPairVector3f()
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val vectors = x1x2ToPairVector3f(context)
|
||||
.then(argPairVector3f()
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val vectors = x1x2ToPairVector3f(context)
|
||||
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "sizeRandom", vectors)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "sizeRandom", vectors)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
fun uniformSize() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("uniformSize")
|
||||
.then(
|
||||
CommandManager.argument("Bool", BoolArgumentType.bool())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val uniform = BoolArgumentType.getBool(context, "Bool")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "uniformSize", uniform)
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
.then(CommandManager.argument("Bool", BoolArgumentType.bool())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val uniform = BoolArgumentType.getBool(context, "Bool")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "uniformSize", uniform)
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
fun velRandom() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("velRandom")
|
||||
.then(
|
||||
argPairVector3f()
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val vectors = x1x2ToPairVector3f(context)
|
||||
.then(argPairVector3f()
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val vectors = x1x2ToPairVector3f(context)
|
||||
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "velRandom", vectors)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "velRandom", vectors)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
fun forceFields() {} // TODO: how?
|
||||
fun forceFields() {} // TODO
|
||||
fun gravity() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("gravity")
|
||||
.then(
|
||||
argVector3f()
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val x1 = FloatArgumentType.getFloat(context, "Min X")
|
||||
val y1 = FloatArgumentType.getFloat(context, "Min Y")
|
||||
val z1 = FloatArgumentType.getFloat(context, "Min Z")
|
||||
.then(argVector3f("X", "Y", "Z")
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val x1 = FloatArgumentType.getFloat(context, "X")
|
||||
val y1 = FloatArgumentType.getFloat(context, "Y")
|
||||
val z1 = FloatArgumentType.getFloat(context, "Z")
|
||||
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "gravity", Vector3f(x1, y1, z1))
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "gravity", Vector3f(x1, y1, z1))
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
fun drag() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("drag")
|
||||
.then(
|
||||
CommandManager.argument("Float", FloatArgumentType.floatArg())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val value = FloatArgumentType.getFloat(context, "Float")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "drag", value)
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
.then(CommandManager.argument("Float", FloatArgumentType.floatArg())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val value = FloatArgumentType.getFloat(context, "Float")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "drag", value)
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
fun minVel() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("minVel")
|
||||
.then(
|
||||
CommandManager.argument("Float", FloatArgumentType.floatArg())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val value = FloatArgumentType.getFloat(context, "Float")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "minVel", value)
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
.then(CommandManager.argument("Float", FloatArgumentType.floatArg())
|
||||
.executes { context ->
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val value = FloatArgumentType.getFloat(context, "Float")
|
||||
val feedback = argUpdateParticleParam(context, particleIndex, "minVel", value)
|
||||
context.source.sendFeedback( { feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
fun lifeTime() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
@@ -372,7 +351,7 @@ class ArgConfigParticleKeys {
|
||||
}
|
||||
|
||||
|
||||
fun argPairVector3f() : RequiredArgumentBuilder<ServerCommandSource, Float> {
|
||||
fun argPairVector3f(): RequiredArgumentBuilder<ServerCommandSource, Float> {
|
||||
return CommandManager.argument("Min X", FloatArgumentType.floatArg())
|
||||
.then(CommandManager.argument("Min Y", FloatArgumentType.floatArg())
|
||||
.then(CommandManager.argument("Min Z", FloatArgumentType.floatArg())
|
||||
@@ -386,10 +365,10 @@ fun argPairVector3f() : RequiredArgumentBuilder<ServerCommandSource, Float> {
|
||||
}
|
||||
|
||||
|
||||
fun argVector3f() : RequiredArgumentBuilder<ServerCommandSource, Float> {
|
||||
return CommandManager.argument("Min X", FloatArgumentType.floatArg())
|
||||
.then(CommandManager.argument("Min Y", FloatArgumentType.floatArg())
|
||||
.then(CommandManager.argument("Min Z", FloatArgumentType.floatArg()))
|
||||
fun argVector3f(xName: String, yName: String, zName: String) : RequiredArgumentBuilder<ServerCommandSource, Float> {
|
||||
return CommandManager.argument(xName, FloatArgumentType.floatArg())
|
||||
.then(CommandManager.argument(yName, FloatArgumentType.floatArg())
|
||||
.then(CommandManager.argument(zName, FloatArgumentType.floatArg()))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -398,12 +377,11 @@ val curves = arrayOf("LINEAR", "SQRT", "EXPONENT", "CUBIC", "SINE", "COSINE", "I
|
||||
|
||||
fun argCurve() : RequiredArgumentBuilder<ServerCommandSource, Float> {
|
||||
return argPairVector3f()
|
||||
.then(
|
||||
CommandManager.argument("Curve", StringArgumentType.string())
|
||||
.suggests { _, builder ->
|
||||
curves.forEach { builder.suggest(it) }
|
||||
CompletableFuture.completedFuture(builder.build())
|
||||
}
|
||||
.then(CommandManager.argument("Curve", StringArgumentType.string())
|
||||
.suggests { _, builder ->
|
||||
curves.forEach { builder.suggest(it) }
|
||||
CompletableFuture.completedFuture(builder.build())
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -433,4 +411,101 @@ fun x1x2ToPairVector3f(context: CommandContext<ServerCommandSource>) : Pair<Vect
|
||||
val y2 = FloatArgumentType.getFloat(context, "Max Y")
|
||||
val z2 = FloatArgumentType.getFloat(context, "Max Z")
|
||||
return Pair(Vector3f(x1, y1, z1), Vector3f(x2, y2, z2))
|
||||
}
|
||||
|
||||
|
||||
fun argAddForceField() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("add")
|
||||
.then(CommandManager.argument("Name", StringArgumentType.string())
|
||||
.then(argVector3f("X Pos", "Y Pos", "Z Pos")
|
||||
.then(CommandManager.argument("Min Force", FloatArgumentType.floatArg())
|
||||
.then(CommandManager.argument("Max Force", FloatArgumentType.floatArg())
|
||||
.then(CommandManager.literal("Sphere")
|
||||
.then(CommandManager.argument("Radius", FloatArgumentType.floatArg())
|
||||
.executes { context -> forceFieldAddSphereExec(context) }
|
||||
)
|
||||
)
|
||||
.then(CommandManager.literal("cube")
|
||||
.then(argVector3f("X Size", "Y Size", "Z Size")
|
||||
.then(argVector3f("X Force", "Y Force", "Z Force")
|
||||
.executes { context -> forceFieldAddCubeExec(context) }
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
fun forceFieldAddSphereExec(context: CommandContext<ServerCommandSource>) : Int {
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val radius = FloatArgumentType.getFloat(context, "Radius")
|
||||
val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID")
|
||||
|
||||
val shape = ForceFieldShape.SPHERE(radius)
|
||||
val forceField = forceFieldGenericParams(context, shape)
|
||||
|
||||
val currentParams = getEmitterParams(emitterIdVal)
|
||||
val forceFields = currentParams!!.particleTypes[particleIndex].forceFields
|
||||
|
||||
val feedback = argUpdateParticleParam(
|
||||
context,
|
||||
particleIndex,
|
||||
"forceFields",
|
||||
forceFields.toMutableList().add(forceField)
|
||||
)
|
||||
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
|
||||
return Command.SINGLE_SUCCESS
|
||||
}
|
||||
|
||||
|
||||
fun forceFieldAddCubeExec(context: CommandContext<ServerCommandSource>) : Int {
|
||||
val particleIndex = IntegerArgumentType.getInteger(context, "Particle Index")
|
||||
val xSize = FloatArgumentType.getFloat(context, "X Size")
|
||||
val ySize = FloatArgumentType.getFloat(context, "Y Size")
|
||||
val zSize = FloatArgumentType.getFloat(context, "Z Size")
|
||||
val xForce = FloatArgumentType.getFloat(context, "X Force")
|
||||
val yForce = FloatArgumentType.getFloat(context, "Y Force")
|
||||
val zForce = FloatArgumentType.getFloat(context, "Z Force")
|
||||
val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID")
|
||||
|
||||
val shape = ForceFieldShape.CUBE(Vector3f(xSize, ySize, zSize), Vector3f(xForce, yForce, zForce))
|
||||
val forceField = forceFieldGenericParams(context, shape)
|
||||
|
||||
val currentParams = getEmitterParams(emitterIdVal)
|
||||
val forceFields = currentParams!!.particleTypes[particleIndex].forceFields
|
||||
|
||||
val feedback = argUpdateParticleParam(
|
||||
context,
|
||||
particleIndex,
|
||||
"forceFields",
|
||||
forceFields.toMutableList().add(forceField)
|
||||
)
|
||||
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
|
||||
return Command.SINGLE_SUCCESS
|
||||
}
|
||||
|
||||
|
||||
fun forceFieldGenericParams(context: CommandContext<ServerCommandSource>, shape: ForceFieldShape) : ForceField {
|
||||
val name = StringArgumentType.getString(context, "Name")
|
||||
val posX = FloatArgumentType.getFloat(context, "X Pos")
|
||||
val posY = FloatArgumentType.getFloat(context, "Y Pos")
|
||||
val posZ = FloatArgumentType.getFloat(context, "Z Pos")
|
||||
val minForce = FloatArgumentType.getFloat(context, "Min Force")
|
||||
val maxForce = FloatArgumentType.getFloat(context, "Max Force")
|
||||
|
||||
return ForceField(
|
||||
name,
|
||||
Vector3f(posX, posY, posZ),
|
||||
Pair(minForce, maxForce),
|
||||
shape
|
||||
)
|
||||
}
|
||||
@@ -88,46 +88,42 @@ val particleConfigKeys = ArgConfigParticleKeys()
|
||||
// output -> register new emitter with a preset
|
||||
fun argCreate() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("create")
|
||||
.then(
|
||||
// [emitter id]
|
||||
CommandManager.argument("Emitter ID", StringArgumentType.string())
|
||||
.then(
|
||||
// [preset emitter id]
|
||||
emitterIdSuggestion
|
||||
.executes { context ->
|
||||
val emitterIdVal = StringArgumentType.getString(context, "Emitter ID")
|
||||
val emitterPresetVal = StringArgumentType.getString(context, "Registered Emitter ID") ?: "DEFAULT"
|
||||
val emitterPresetParams = getEmitterParams(emitterPresetVal)
|
||||
.then(CommandManager.argument("Emitter ID", StringArgumentType.string())
|
||||
.then(emitterIdSuggestion
|
||||
.executes { context ->
|
||||
val emitterIdVal = StringArgumentType.getString(context, "Emitter ID")
|
||||
val emitterPresetVal = StringArgumentType.getString(context, "Registered Emitter ID") ?: "DEFAULT"
|
||||
val emitterPresetParams = getEmitterParams(emitterPresetVal)
|
||||
|
||||
var newEmitterId = "NULL"
|
||||
val emitterRegisterData: Pair<String, Boolean>
|
||||
var newEmitterId = "NULL"
|
||||
val emitterRegisterData: Pair<String, Boolean>
|
||||
|
||||
if (emitterPresetParams != null) {
|
||||
emitterRegisterData = addToEmitterRegister(emitterIdVal, emitterPresetParams)
|
||||
newEmitterId = emitterRegisterData.first
|
||||
}
|
||||
else { emitterRegisterData = Pair("NULL", false) }
|
||||
if (emitterPresetParams != null) {
|
||||
emitterRegisterData = addToEmitterRegister(emitterIdVal, emitterPresetParams)
|
||||
newEmitterId = emitterRegisterData.first
|
||||
}
|
||||
else { emitterRegisterData = Pair("NULL", false) }
|
||||
|
||||
val feedback = if (emitterRegisterData.second) {
|
||||
Text.literal("BPS - Created particle emitter with ID \"$newEmitterId\".\n" +
|
||||
"BPS - This emitter will be removed on server restart! Use \"/ManageEmitters copy\" to save the data to your clipboard!")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(0, 200, 0).rgb)))
|
||||
}
|
||||
else if (newEmitterId !in allEmitterIds) {
|
||||
Text.literal("BPS - Preset Emitter ID \"$emitterPresetVal\" doesn't exist!\n" +
|
||||
"BPS - Use \"/ManageEmitters list\" to view all Emitter ID's.")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(200, 0, 0).rgb)))
|
||||
}
|
||||
else {
|
||||
Text.literal("BPS - Emitter ID \"$newEmitterId\" already exists\n" +
|
||||
"BPS - Use \"/ManageEmitters list\" to view all Emitter ID's.")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(200, 0, 0).rgb)))
|
||||
}
|
||||
val feedback = if (emitterRegisterData.second) {
|
||||
Text.literal("BPS - Created particle emitter with ID \"$newEmitterId\".\n" +
|
||||
"BPS - This emitter will be removed on server restart! Use \"/ManageEmitters copy\" to save the data to your clipboard!")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(0, 200, 0).rgb)))
|
||||
}
|
||||
else if (newEmitterId !in allEmitterIds) {
|
||||
Text.literal("BPS - Preset Emitter ID \"$emitterPresetVal\" doesn't exist!\n" +
|
||||
"BPS - Use \"/ManageEmitters list\" to view all Emitter ID's.")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(200, 0, 0).rgb)))
|
||||
}
|
||||
else {
|
||||
Text.literal("BPS - Emitter ID \"$newEmitterId\" already exists\n" +
|
||||
"BPS - Use \"/ManageEmitters list\" to view all Emitter ID's.")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(200, 0, 0).rgb)))
|
||||
}
|
||||
|
||||
context.source.sendFeedback( { feedback }, false )
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
context.source.sendFeedback( { feedback }, false )
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -136,26 +132,24 @@ fun argCreate() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
// output -> removes the particle with that id
|
||||
fun argRemove() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("remove")
|
||||
.then(
|
||||
// [emitter id]
|
||||
emitterIdSuggestion
|
||||
.executes { context ->
|
||||
val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID") ?: "NULL"
|
||||
val isRemoved = removeFromEmitterRegister(emitterIdVal)
|
||||
.then(emitterIdSuggestion
|
||||
.executes { context ->
|
||||
val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID") ?: "NULL"
|
||||
val isRemoved = removeFromEmitterRegister(emitterIdVal)
|
||||
|
||||
val feedback = if (isRemoved) {
|
||||
Text.literal("BPS - Removed particle emitter with ID \"$emitterIdVal\".")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(0, 200, 0).rgb)))
|
||||
}
|
||||
else {
|
||||
Text.literal("BPS - Emitter ID \"$emitterIdVal\" doesn't exist or is reserved!\n" +
|
||||
"BPS - Use \"/ManageEmitters list\" to view all Emitter ID's.")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(200, 0, 0).rgb)))
|
||||
}
|
||||
|
||||
context.source.sendFeedback( { feedback }, false )
|
||||
Command.SINGLE_SUCCESS
|
||||
val feedback = if (isRemoved) {
|
||||
Text.literal("BPS - Removed particle emitter with ID \"$emitterIdVal\".")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(0, 200, 0).rgb)))
|
||||
}
|
||||
else {
|
||||
Text.literal("BPS - Emitter ID \"$emitterIdVal\" doesn't exist or is reserved!\n" +
|
||||
"BPS - Use \"/ManageEmitters list\" to view all Emitter ID's.")
|
||||
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(Color(200, 0, 0).rgb)))
|
||||
}
|
||||
|
||||
context.source.sendFeedback( { feedback }, false )
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -184,37 +178,35 @@ fun argList() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
// output -> give player a command block with the particle params (should be paste-able in kotlin)
|
||||
fun argCopy() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("copy")
|
||||
.then(
|
||||
// [emitter id]
|
||||
emitterIdSuggestion
|
||||
.executes { context ->
|
||||
val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID")
|
||||
val commandBlock = makeCommandBlock(
|
||||
emitterParamsToJson(
|
||||
getEmitterParams(
|
||||
emitterIdVal
|
||||
)!!
|
||||
)
|
||||
.then(emitterIdSuggestion
|
||||
.executes { context ->
|
||||
val emitterIdVal = StringArgumentType.getString(context, "Registered Emitter ID")
|
||||
val commandBlock = makeCommandBlock(
|
||||
emitterParamsToJson(
|
||||
getEmitterParams(
|
||||
emitterIdVal
|
||||
)!!
|
||||
)
|
||||
)
|
||||
|
||||
val feedback: MutableText
|
||||
val feedback: MutableText
|
||||
|
||||
if (context.source.server.areCommandBlocksEnabled()) {
|
||||
feedback = Text.literal("BPS - Copied Emitter data as a JSON. Place down the command block and copy it to your clipboard to use the value.")
|
||||
.setStyle(Style.EMPTY.withColor(Color(0, 200, 0).rgb))
|
||||
}
|
||||
else {
|
||||
feedback = Text.literal("BPS - Could not copy Emitter data: Command blocks aren't enabled. Go to server.properties and enable command blocks before retrying.")
|
||||
.setStyle(Style.EMPTY.withColor(Color(200, 0, 0).rgb))
|
||||
if (context.source.server.areCommandBlocksEnabled()) {
|
||||
feedback = Text.literal("BPS - Copied Emitter data as a JSON. Place down the command block and copy it to your clipboard to use the value.")
|
||||
.setStyle(Style.EMPTY.withColor(Color(0, 200, 0).rgb))
|
||||
}
|
||||
else {
|
||||
feedback = Text.literal("BPS - Could not copy Emitter data: Command blocks aren't enabled. Go to server.properties and enable command blocks before retrying.")
|
||||
.setStyle(Style.EMPTY.withColor(Color(200, 0, 0).rgb))
|
||||
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
|
||||
|
||||
context.source.player?.inventory?.insertStack(commandBlock)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
|
||||
|
||||
context.source.player?.inventory?.insertStack(commandBlock)
|
||||
context.source.sendFeedback({ feedback }, false)
|
||||
Command.SINGLE_SUCCESS
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -226,42 +218,39 @@ fun argCopy() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
// output -> update the selected parameter of the selected emitter id to the new value
|
||||
fun argConfig() : LiteralArgumentBuilder<ServerCommandSource> {
|
||||
return CommandManager.literal("config")
|
||||
.then(
|
||||
emitterIdSuggestion
|
||||
.then(
|
||||
CommandManager.literal("EMITTER")
|
||||
.then(emitterConfigKeys.maxCount())
|
||||
.then(emitterConfigKeys.spawnsPerTick())
|
||||
.then(emitterConfigKeys.loopDur())
|
||||
.then(emitterConfigKeys.loopDelay())
|
||||
.then(emitterConfigKeys.loopCount())
|
||||
)
|
||||
.then(
|
||||
CommandManager.argument("Particle Index", IntegerArgumentType.integer())
|
||||
.suggests { context, builder ->
|
||||
val emitterId = StringArgumentType.getString(context, "Registered Emitter ID")
|
||||
.then(emitterIdSuggestion
|
||||
.then(CommandManager.literal("EMITTER")
|
||||
.then(emitterConfigKeys.maxCount())
|
||||
.then(emitterConfigKeys.spawnsPerTick())
|
||||
.then(emitterConfigKeys.loopDur())
|
||||
.then(emitterConfigKeys.loopDelay())
|
||||
.then(emitterConfigKeys.loopCount())
|
||||
)
|
||||
.then(CommandManager.argument("Particle Index", IntegerArgumentType.integer())
|
||||
.suggests { context, builder ->
|
||||
val emitterId = StringArgumentType.getString(context, "Registered Emitter ID")
|
||||
|
||||
getEmitterParams(emitterId)?.particleTypes?.indices?.forEach {
|
||||
builder.suggest(it)
|
||||
}
|
||||
getEmitterParams(emitterId)?.particleTypes?.indices?.forEach {
|
||||
builder.suggest(it)
|
||||
}
|
||||
|
||||
CompletableFuture.completedFuture(builder.build())
|
||||
}
|
||||
.then(particleConfigKeys.shape())
|
||||
.then(particleConfigKeys.blockCurve())
|
||||
.then(particleConfigKeys.rotRandom())
|
||||
.then(particleConfigKeys.rotVelRandom())
|
||||
.then(particleConfigKeys.sizeRandom())
|
||||
.then(particleConfigKeys.uniformSize())
|
||||
.then(particleConfigKeys.velRandom())
|
||||
//.then(particleConfigKeys.forceFields())
|
||||
.then(particleConfigKeys.gravity())
|
||||
.then(particleConfigKeys.drag())
|
||||
.then(particleConfigKeys.minVel())
|
||||
.then(particleConfigKeys.lifeTime())
|
||||
.then(particleConfigKeys.rotVelCurve())
|
||||
.then(particleConfigKeys.sizeCurve())
|
||||
)
|
||||
CompletableFuture.completedFuture(builder.build())
|
||||
}
|
||||
.then(particleConfigKeys.shape())
|
||||
.then(particleConfigKeys.blockCurve())
|
||||
.then(particleConfigKeys.rotRandom())
|
||||
.then(particleConfigKeys.rotVelRandom())
|
||||
.then(particleConfigKeys.sizeRandom())
|
||||
.then(particleConfigKeys.uniformSize())
|
||||
.then(particleConfigKeys.velRandom())
|
||||
//.then(particleConfigKeys.forceFields())
|
||||
.then(particleConfigKeys.gravity())
|
||||
.then(particleConfigKeys.drag())
|
||||
.then(particleConfigKeys.minVel())
|
||||
.then(particleConfigKeys.lifeTime())
|
||||
.then(particleConfigKeys.rotVelCurve())
|
||||
.then(particleConfigKeys.sizeCurve())
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -285,4 +274,4 @@ fun makeCommandBlock(emitterData: Map<String, Any>): ItemStack {
|
||||
i.set(DataComponentTypes.BLOCK_ENTITY_DATA, component)
|
||||
|
||||
return i
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.bytedice.bde_particles.particles
|
||||
|
||||
data class ForceField (
|
||||
val x: Float = 0.0f,
|
||||
val y: Float = 0.0f,
|
||||
val z: Float = 0.0f,
|
||||
val minForce: Float = 0.0f,
|
||||
val maxForce: Float = 0.0f,
|
||||
val shape: ForceFieldShape = ForceFieldShape.Sphere()
|
||||
)
|
||||
import org.joml.Vector3f
|
||||
|
||||
data class ForceField (
|
||||
val name: String = "DEFAULT",
|
||||
val pos: Vector3f = Vector3f(0.0f, 0.0f, 0.0f),
|
||||
val force: Pair<Float, Float> = Pair(0.0f, 1.0f),
|
||||
val shape: ForceFieldShape = ForceFieldShape.SPHERE()
|
||||
)
|
||||
@@ -42,21 +42,21 @@ class Particle(private val particleParams: ParticleParams) {
|
||||
val newSpawnPos: Vector3f
|
||||
|
||||
when (shape) {
|
||||
is SpawningShape.Circle -> {
|
||||
is SpawningShape.CIRCLE -> {
|
||||
val posInCircle = randomInCircle(shape.radius)
|
||||
newSpawnPos = Vector3f(posInCircle.x, 0.0f, posInCircle.y)
|
||||
}
|
||||
|
||||
is SpawningShape.Sphere -> {
|
||||
is SpawningShape.SPHERE -> {
|
||||
newSpawnPos = randomInSphere(shape.radius)
|
||||
}
|
||||
|
||||
is SpawningShape.Rect -> {
|
||||
is SpawningShape.RECT -> {
|
||||
val posInRect = randomInRect(shape.size)
|
||||
newSpawnPos = Vector3f(posInRect.x, 0.0f, posInRect.y)
|
||||
}
|
||||
|
||||
is SpawningShape.Cube -> {
|
||||
is SpawningShape.CUBE -> {
|
||||
newSpawnPos = randomInCube(shape.size)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.joml.Vector3f
|
||||
* @param sizeCurve A curve which the size gets multiplied by during the particle's lifetime.
|
||||
*/
|
||||
data class ParticleParams (
|
||||
var shape: SpawningShape? = SpawningShape.Circle(3.0f),
|
||||
var shape: SpawningShape? = SpawningShape.CIRCLE(3.0f),
|
||||
var blockCurve: Array<String> = arrayOf("minecraft:shroomlight", "minecraft:orange_concrete", "minecraft:orange_stained_glass", "minecraft:gray_stained_glass", "minecraft:light_gray_stained_glass"),
|
||||
var rotRandom: Pair<Vector3f, Vector3f> = Pair(Vector3f(0.0f, 0.0f, 0.0f), Vector3f(360.0f, 360.0f, 360.0f)),
|
||||
var rotVelRandom: Pair<Vector3f, Vector3f> = Pair(Vector3f(-0.2f, -0.2f, -0.2f), Vector3f(0.2f, 0.2f, 0.2f)),
|
||||
|
||||
@@ -4,20 +4,15 @@ import org.joml.Vector2f
|
||||
import org.joml.Vector3f
|
||||
|
||||
sealed class SpawningShape {
|
||||
data class Circle(val radius: Float = 1.0f) : SpawningShape()
|
||||
data class Rect (val size: Vector2f = Vector2f(1.0f, 1.0f)) : SpawningShape()
|
||||
data class Cube (val size: Vector3f = Vector3f(1.0f, 1.0f, 1.0f)) : SpawningShape()
|
||||
data class Sphere(val radius: Float = 1.0f) : SpawningShape()
|
||||
data class CIRCLE(val radius: Float = 1.0f) : SpawningShape()
|
||||
data class RECT (val size: Vector2f = Vector2f(1.0f, 1.0f)) : SpawningShape()
|
||||
data class CUBE (val size: Vector3f = Vector3f(1.0f, 1.0f, 1.0f)) : SpawningShape()
|
||||
data class SPHERE(val radius: Float = 1.0f) : SpawningShape()
|
||||
}
|
||||
|
||||
sealed class ForceFieldShape {
|
||||
data class Sphere(
|
||||
val pos: Vector3f = Vector3f(0.0f, 0.0f, 0.0f),
|
||||
val radius: Float = 1.0f
|
||||
) : ForceFieldShape()
|
||||
|
||||
data class Rect(
|
||||
val pos: Vector3f = Vector3f(0.0f, 0.0f, 0.0f),
|
||||
data class SPHERE(val radius: Float = 1.0f) : ForceFieldShape()
|
||||
data class CUBE(
|
||||
val size: Vector3f = Vector3f(1.0f, 1.0f, 1.0f),
|
||||
val forceDir: Vector3f = Vector3f(0.0f, 0.0f, 0.0f) // 0.0 on all means from center
|
||||
) : ForceFieldShape()
|
||||
|
||||
Reference in New Issue
Block a user