Fabric
This page describes how to integrate Lamp with Fabric, as well as what to expect out of it.
Setting up
Prerequisites
Java 21 or newer
Adding Lamp dependency
To add Lamp to your project, add the following (depending on your project structure):
<dependencies>
<!-- Required for all platforms -->
<dependency>
<groupId>io.github.revxrsal</groupId>
<artifactId>lamp.common</artifactId>
<version>[VERSION]</version>
</dependency>
<!-- Fabric module -->
<dependency>
<groupId>io.github.revxrsal</groupId>
<artifactId>lamp.fabric</artifactId>
<version>[VERSION]</version>
</dependency>
<!-- Optional: Brigadier module -->
<dependency>
<groupId>io.github.revxrsal</groupId>
<artifactId>lamp.brigadier</artifactId>
<version>[VERSION]</version>
</dependency>
</dependencies>
Latest version:
Optional: Preserve parameter names
Lamp identifies parameters by their names and uses them to generate relevant command metadata. By default, Java does not preserve parameter names reflectively. You need to add the following to your project:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<compilerArgs>
<!-- Preserves parameter names -->
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
Fabric-specific annotations
@CommandPermission
@CommandPermission
Adds a command permission level for the given command
Supported Fabric types
net.minecraft.server.command.ServerCommandSource
and its subclasses in place of CommandActornet.minecraft.server.network.ServerPlayerEntity
net.minecraft.world.World
Example
public class MyMod implements ModInitializer {
@Override
public void onInitialize() {
var lamp = FabricLamp.builder(this).build();
lamp.register(new MyCommand());
}
public class MyCommand {
@Command("hello")
@Description("Sends a hello message")
@CommandPermission(4)
public void hello(FabricCommandActor actor) {
actor.reply("Hello from Fabric mod!");
}
}
}
Last updated
Was this helpful?