mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 03:26:44 +01:00
Added a command for changing and resetting the sky angle
This commit is contained in:
parent
c63bebdce1
commit
85467ee7fe
3 changed files with 37 additions and 0 deletions
|
@ -0,0 +1,33 @@
|
|||
package com.minelittlepony.unicopia.command;
|
||||
|
||||
import com.minelittlepony.unicopia.server.world.UnicopiaWorldProperties;
|
||||
import com.mojang.brigadier.arguments.FloatArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
class SkyAngleCommand {
|
||||
static LiteralArgumentBuilder<ServerCommandSource> create() {
|
||||
return CommandManager.literal("skyangle").requires(s -> s.hasPermissionLevel(2))
|
||||
.executes(context -> get(context.getSource()))
|
||||
.then(CommandManager.literal("set")
|
||||
.executes(context -> set(context.getSource(), 0))
|
||||
.then(CommandManager.argument("angle", FloatArgumentType.floatArg(0, 360))
|
||||
.executes(context -> set(context.getSource(), FloatArgumentType.getFloat(context, "angle")))));
|
||||
}
|
||||
|
||||
static int get(ServerCommandSource source) throws CommandSyntaxException {
|
||||
source.sendFeedback(() -> Text.translatable("commands.skyangle.get", UnicopiaWorldProperties.forWorld(source.getWorld()).getTangentalSkyAngle()), true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set(ServerCommandSource source, float newAngle) {
|
||||
UnicopiaWorldProperties.forWorld(source.getWorld()).setTangentalSkyAngle(newAngle);
|
||||
source.sendFeedback(() -> Text.translatable("commands.skyangle.set", newAngle), true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -14,6 +14,7 @@ class UnicopiaCommand {
|
|||
.then(SpeciesCommand.create(environment))
|
||||
.then(RacelistCommand.create())
|
||||
.then(WorldTribeCommand.create())
|
||||
.then(SkyAngleCommand.create())
|
||||
.then(GravityCommand.create())
|
||||
.then(DisguiseCommand.create(registries))
|
||||
.then(CastCommand.create(registries))
|
||||
|
|
|
@ -628,6 +628,9 @@
|
|||
"commands.race.permission": "Selected Race is not permitted by your current server",
|
||||
"commands.race.fail": "\"%s\" is not a recognised Race",
|
||||
|
||||
"commands.skyangle.get": "The current angle of the sun is %sdeg",
|
||||
"commands.skyangle.set": "Changed sky angle to %sdeg",
|
||||
|
||||
"commands.race.tell.self": "You are a ",
|
||||
"commands.race.tell.self.alt": "You are an ",
|
||||
"commands.race.tell.other": "%s is a ",
|
||||
|
|
Loading…
Reference in a new issue