Push 1.2.3
This commit is contained in:
parent
3275bd4e8c
commit
883d41ecc9
5 changed files with 75 additions and 7 deletions
|
@ -40,6 +40,7 @@ import org.slf4j.Logger;
|
|||
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import dev.zontreck.otemod.commands.DelHomeCommand;
|
||||
import dev.zontreck.otemod.commands.FlyCommand;
|
||||
import dev.zontreck.otemod.commands.HomeCommand;
|
||||
import dev.zontreck.otemod.commands.HomesCommand;
|
||||
import dev.zontreck.otemod.commands.SetHomeCommand;
|
||||
|
@ -146,6 +147,8 @@ public class OTEMod
|
|||
SetHomeCommand.register(ev.getDispatcher());
|
||||
HomeCommand.register(ev.getDispatcher());
|
||||
DelHomeCommand.register(ev.getDispatcher());
|
||||
|
||||
FlyCommand.register(ev.getDispatcher());
|
||||
}
|
||||
|
||||
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
||||
|
|
65
src/main/java/dev/zontreck/otemod/commands/FlyCommand.java
Normal file
65
src/main/java/dev/zontreck/otemod/commands/FlyCommand.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
package dev.zontreck.otemod.commands;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.math.Vector3d;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.chat.ChatColor;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.contents.TranslatableContents;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.server.command.TextComponentHelper;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
public class FlyCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("fly").executes(FlyCommand::Fly));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int Fly(CommandContext<CommandSourceStack> ctx2)
|
||||
{
|
||||
// Request homes
|
||||
// String homeName = "";
|
||||
// CommandSourceStack ctx = ctx2.getSource();
|
||||
// homeName = StringArgumentType.getString(ctx2, "nickname");
|
||||
// if(homeName==null)return 0;
|
||||
CommandSourceStack ctx = ctx2.getSource();
|
||||
if(! ctx.isPlayer())
|
||||
{
|
||||
|
||||
ctx.sendFailure(MutableComponent.create( new TranslatableContents("dev.zontreck.otemod.msgs.homes.only_player")));
|
||||
return 1;
|
||||
}
|
||||
ServerPlayer p = ctx.getPlayer();
|
||||
|
||||
if(p.getAbilities().mayfly){
|
||||
p.getAbilities().mayfly=false;
|
||||
p.getAbilities().flying=false;
|
||||
p.onUpdateAbilities();
|
||||
|
||||
ctx.sendSuccess(Component.literal(ChatColor.BOLD + "[" + ChatColor.DARK_GREEN + "OTEMOD" + ChatColor.WHITE + "] "+ChatColor.resetChat() + ChatColor.DARK_PURPLE + "Your ability to fly has been disabled"), false);
|
||||
}else {
|
||||
p.getAbilities().mayfly=true;
|
||||
p.onUpdateAbilities();
|
||||
|
||||
ctx.sendSuccess(Component.literal(ChatColor.BOLD + "[" + ChatColor.DARK_GREEN + "OTEMOD" + ChatColor.WHITE + "] "+ChatColor.resetChat() + ChatColor.DARK_PURPLE + "You can now fly"), false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue