Add /fly command
This commit is contained in:
parent
6c8b3433fe
commit
ca4acc3011
@ -9,6 +9,7 @@ import java.nio.file.Path;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import party._2a03.mc.command.ConfigCommand;
|
||||
import party._2a03.mc.command.FlyCommand;
|
||||
import party._2a03.mc.command.HatCommand;
|
||||
import party._2a03.mc.command.HeadCommand;
|
||||
import party._2a03.mc.command.HomeCommand;
|
||||
@ -43,6 +44,7 @@ public class MinecraftTweaks2a03 implements ModInitializer {
|
||||
LOGGER.info("Registering 2a03.party commands");
|
||||
CommandRegistry.INSTANCE.register(false, dispatcher -> {
|
||||
ConfigCommand.register(dispatcher);
|
||||
FlyCommand.register(dispatcher);
|
||||
HatCommand.register(dispatcher);
|
||||
HeadCommand.register(dispatcher);
|
||||
HomeCommand.register(dispatcher);
|
||||
|
26
src/main/java/party/_2a03/mc/command/FlyCommand.java
Normal file
26
src/main/java/party/_2a03/mc/command/FlyCommand.java
Normal file
@ -0,0 +1,26 @@
|
||||
package party._2a03.mc.command;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.LiteralText;
|
||||
|
||||
public class FlyCommand {
|
||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||
dispatcher.register(CommandManager.literal("fly").executes(ctx -> {
|
||||
ServerCommandSource source = ctx.getSource();
|
||||
ServerPlayerEntity sender = source.getPlayer();
|
||||
boolean flight = sender.abilities.allowFlying;
|
||||
sender.abilities.allowFlying = !flight;
|
||||
if (!flight)
|
||||
source.sendFeedback(new LiteralText("I wanna fly like an eagle... to the sea!"), true);
|
||||
else {
|
||||
source.sendFeedback(new LiteralText("Flight disabled"), true);
|
||||
sender.abilities.flying = false;
|
||||
}
|
||||
sender.sendAbilitiesUpdate();
|
||||
return 1;
|
||||
}));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user