ArgumentReader
Argument readers are a general access point for obtaining argument values from the command context.
Accessors are defined as extensions methods on the reader allowing reading of arguments with specific descriptors from contexts with specific source types S
Author
Cypher121
Samples
import com.mojang.brigadier.CommandDispatcher
import net.minecraft.command.argument.PosArgument
import net.minecraft.command.argument.Vec3ArgumentType
import net.minecraft.network.MessageType
import net.minecraft.server.command.ServerCommandSource
import net.minecraft.text.Text
import net.minecraft.util.math.Vec3d
import org.quiltmc.qkl.wrapper.minecraft.brigadier.*
import org.quiltmc.qkl.wrapper.minecraft.brigadier.argument.*
import org.quiltmc.qkl.wrapper.minecraft.brigadier.util.entity
import org.quiltmc.qkl.wrapper.minecraft.brigadier.util.required
import org.quiltmc.qkl.wrapper.minecraft.brigadier.util.sendFeedback
import org.quiltmc.qkl.wrapper.minecraft.brigadier.util.server
import kotlin.random.Random
fun main() {
//sampleStart
//some special command source your code needs
//e.g. commands coming from external integrations
abstract class CustomSource {
abstract fun calculateVec3(pos: PosArgument): Vec3d
abstract fun useVec3ForSomething(vec: Vec3d)
}
//can use any name including `value`
//`custom` added for clarity
fun ArgumentReader<CustomSource, DefaultArgumentDescriptor<Vec3ArgumentType>>.customValue(): Vec3d =
context.source.calculateVec3(posArgument())
val dispatcher: CommandDispatcher<CustomSource> = stub()
dispatcher.register("customSourceCommand") {
required(vec3("pos")) { getPos ->
execute {
val vec = getPos().customValue()
source.useVec3ForSomething(vec)
}
}
}
//sampleEnd
}
Constructors
Properties
Extensions
Reads the Vec2f value from the argument in the receiver ArgumentReader, converting the contained PosArgument to an absolute rotation.
Reads the Identifier value from the argument in the receiver ArgumentReader as an Advancement.
Reads the Identifier value from the argument in the receiver ArgumentReader as a LootFunction.
Reads the Identifier value from the argument in the receiver ArgumentReader as a LootCondition.
Reads the Identifier value from the argument in the receiver ArgumentReader as a Recipe.
Reads all score holder names from the argument in the receiver ArgumentReader.
Reads the matched CommandFunctions from the argument in the receiver ArgumentReader.
Reads the collection of CommandFunctions from the argument in the receiver ArgumentReader.
Reads the collection of entities from the argument in the receiver ArgumentReader.
Reads the collection of players from the argument in the receiver ArgumentReader.
Reads the collection of entities from the argument in the receiver ArgumentReader.
Reads the collection of players from the argument in the receiver ArgumentReader.
Reads the BlockPos value from the argument in the receiver ArgumentReader.
Reads the SignedMessage value from the argument in the receiver ArgumentReader.
Reads the entity summon Identifier value of the argument in the receiver ArgumentReader.
Reads the Entity value from the argument in the receiver ArgumentReader.
Reads the enum value of type T from the argument in the receiver ArgumentReader.
Reads the string value from the argument in the receiver ArgumentReader.
Reads the string value from the argument in the receiver ArgumentReader and converts it to a value of type T according to the map provided when creating the argument.
Reads the ServerWorld value for the selected dimension from the argument in the receiver ArgumentReader.
Reads the float value from the argument in the receiver ArgumentReader.
Reads the BlockPos value from the argument in the receiver ArgumentReader.
Reads the ColumnPos value from the argument in the receiver ArgumentReader.
Reads the Vec2f value from the argument in the receiver ArgumentReader.
Reads the Vec3d value from the argument in the receiver ArgumentReader.
Reads the GameProfile value from the argument in the receiver ArgumentReader.
Reads the Team value from the argument in the receiver ArgumentReader.
Reads the ServerPlayerEntity value from the argument in the receiver ArgumentReader.
Reads the ScoreboardObjective value from the argument in the receiver ArgumentReader.
Reads the score holder name from the argument in the receiver ArgumentReader.
Reads all score holder names from the argument in the receiver ArgumentReader.
Reads the message's Text value from the argument in the receiver ArgumentReader.
Reads the ScoreboardObjective value from the argument in the receiver ArgumentReader.