當前位置: 首頁>>代碼示例>>Java>>正文


Java CommandBase類代碼示例

本文整理匯總了Java中net.minecraft.command.CommandBase的典型用法代碼示例。如果您正苦於以下問題:Java CommandBase類的具體用法?Java CommandBase怎麽用?Java CommandBase使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CommandBase類屬於net.minecraft.command包,在下文中一共展示了CommandBase類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: actorFromArgs

import net.minecraft.command.CommandBase; //導入依賴的package包/類
/**
 * Create an actor from command line arguments (i.e. String array).
 * Description of every element in array:
 *
 * 1. Ignored (since it's filename)
 * 2. Name tag
 * 3. Model name
 * 4. Skin resource location
 * 5. Invincible flag (boolean)
 *
 * And of course, all of those arguments are optional (i.e. have default
 * values).
 */
public static EntityActor actorFromArgs(String[] args, World world) throws CommandException
{
    EntityActor actor = null;

    String name = args.length >= 2 ? args[1] : "";
    String model = args.length >= 3 ? args[2] : "";
    String skin = args.length >= 4 ? args[3] : "";
    boolean invincible = args.length >= 5 ? CommandBase.parseBoolean(args[4]) : false;

    actor = new EntityActor(world);
    actor.modify(MorphUtils.morphFromModel(model, skin), false, false, true);
    actor.setEntityInvulnerable(invincible);
    actor.setCustomNameTag(name);

    return actor;
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:30,代碼來源:CommandAction.java

示例2: execute

import net.minecraft.command.CommandBase; //導入依賴的package包/類
/**
 * Callback for when the command is executed
 */
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if(args.length < 1)
    {
        sender.addChatMessage(new TextComponentString(CommandBase.joinNiceStringFromCollection(commandMap.keySet())));
    }
    else
    {
        ICommand cmd = getCommandMap().get(args[0]);

        if(cmd == null)
        {
            throw new CommandException("commands.tree_base.invalid_cmd", args[0]);
        }
        else if(!cmd.checkPermission(server, sender))
        {
            throw new CommandException("commands.generic.permission");
        }
        else
        {
            cmd.execute(server, sender, shiftArgs(args));
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:29,代碼來源:CommandTreeBase.java

示例3: execute

import net.minecraft.command.CommandBase; //導入依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length == 0) {
        throw new CommandException("nosubcommandspecified");
    }
    final Optional<CommandBase> first = childCommands
            .stream()
            .sorted(Comparator.comparing(ICommand::getCommandName))
            .filter(command -> command.getCommandName().equals(args[0]))
            .findFirst();
    if (!first.isPresent()) {
        throw new CommandException("nosuchsubcommand");
    }
    final CommandBase commandBase = first.get();

    final String[] parameters = Arrays.copyOfRange(args, 1, args.length);

    commandBase.execute(server, sender, parameters);
}
 
開發者ID:AtomicBlom,項目名稱:ShearMadness,代碼行數:20,代碼來源:ShearMadnessCommand.java

示例4: getTabCompletionOptions

import net.minecraft.command.CommandBase; //導入依賴的package包/類
@Override
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) {

    if (args.length <= 1) {
        return childCommands
                .stream()
                .map(ICommand::getCommandName)
                .sorted()
                .filter(command -> command.startsWith(args[0]))
                .collect(Collectors.toList());
    }

    final Optional<CommandBase> first = childCommands
            .stream()
            .sorted(Comparator.comparing(ICommand::getCommandName))
            .filter(command -> command.getCommandName() == args[0])
            .findFirst();

    if (!first.isPresent()) {
        return Lists.newArrayList();
    }

    final String[] parameters = Arrays.copyOfRange(args, 1, args.length - 2);

    return first.get().getTabCompletionOptions(server, sender, parameters, pos);
}
 
開發者ID:AtomicBlom,項目名稱:ShearMadness,代碼行數:27,代碼來源:ShearMadnessCommand.java

示例5: execute

import net.minecraft.command.CommandBase; //導入依賴的package包/類
/**
 * Execute the command
 *
 * This method basically delegates the execution to the matched sub-command,
 * if the command was found, otherwise it shows usage message. */
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 1)
    {
        throw new WrongUsageException(this.getCommandUsage(sender));
    }

    CommandBase command = this.subcommands.get(args[0]);

    if (args.length == 2 && args[1].equals("-h"))
    {
        throw new WrongUsageException(command.getCommandUsage(sender));
    }

    if (command != null)
    {
        command.execute(server, sender, dropFirstArgument(args));

        return;
    }

    throw new WrongUsageException(this.getCommandUsage(sender));
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:30,代碼來源:SubCommandBase.java

示例6: execute

import net.minecraft.command.CommandBase; //導入依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 1)
    {
        throw new WrongUsageException(this.getCommandUsage(sender));
    }

    EntityPlayer player = getCommandSenderAsPlayer(sender);

    if (args.length >= 4)
    {
        BlockPos pos = CommandBase.parseBlockPos(sender, args, 1, false);
        TileEntity tile = sender.getEntityWorld().getTileEntity(pos);

        if (tile instanceof TileEntityDirector)
        {
            ((TileEntityDirector) tile).startRecording(args[0], player);
        }
    }
    else
    {
        CommonProxy.manager.startRecording(args[0], player, Mode.ACTIONS, true, null);
    }
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:26,代碼來源:SubCommandActionRecord.java

示例7: execute

import net.minecraft.command.CommandBase; //導入依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	EntityPlayerMP player = CommandBase.getCommandSenderAsPlayer(sender);
	
	if(args.length == 0) {
		throw new WrongUsageException("No parameters given!");
	}
	
	String newName = Strings.join(args, " ").trim();
	
	if(newName.isEmpty()) {
		return;
	}
	
	ItemStack itemStack = player.getHeldItemMainhand();
	
	if(itemStack != null) {
		itemStack.setStackDisplayName(newName);
	}
}
 
開發者ID:tiffit,項目名稱:TaleCraft,代碼行數:21,代碼來源:RenameCommand.java

示例8: execute_expand

import net.minecraft.command.CommandBase; //導入依賴的package包/類
private void execute_expand(String[] args, EntityPlayerMP player, ICommandSender sender) throws CommandException {
	if(args.length == 2) {
		int value = CommandBase.parseInt(args[1]);

		int[] bounds = WandItem.getBoundsFromPlayerOrNull(player);
		if(bounds == null) {
			throw new WrongUsageException("You didn't select a region with your wand.");
		}

		int ix = bounds[0] - value;
		int iy = bounds[1] - value;
		int iz = bounds[2] - value;
		int ax = bounds[3] + value;
		int ay = bounds[4] + value;
		int az = bounds[5] + value;

		WandItem.setBounds(player, ix, iy, iz, ax, ay, az);
		return;
	} else {
		throw new WrongUsageException("Missing parameters! /tc_wand expand <val>");
	}
}
 
開發者ID:tiffit,項目名稱:TaleCraft,代碼行數:23,代碼來源:WandCommand.java

示例9: execute_expand_h

import net.minecraft.command.CommandBase; //導入依賴的package包/類
private void execute_expand_h(String[] args, EntityPlayerMP player, ICommandSender sender) throws CommandException {
	if(args.length == 2) {
		int value = CommandBase.parseInt(args[1]);

		int[] bounds = WandItem.getBoundsFromPlayerOrNull(player);
		if(bounds == null) {
			throw new WrongUsageException("You didn't select a region with your wand.");
		}

		int ix = bounds[0] - value;
		int iy = bounds[1];
		int iz = bounds[2] - value;
		int ax = bounds[3] + value;
		int ay = bounds[4];
		int az = bounds[5] + value;

		WandItem.setBounds(player, ix, iy, iz, ax, ay, az);
		return;
	} else {
		throw new WrongUsageException("Missing parameters! /tc_wand expand <val>");
	}
}
 
開發者ID:tiffit,項目名稱:TaleCraft,代碼行數:23,代碼來源:WandCommand.java

示例10: execute_expand_v

import net.minecraft.command.CommandBase; //導入依賴的package包/類
private void execute_expand_v(String[] args, EntityPlayerMP player, ICommandSender sender) throws CommandException {
	if(args.length == 2) {
		int value = CommandBase.parseInt(args[1], 0, 128);

		int[] bounds = WandItem.getBoundsFromPlayerOrNull(player);
		if(bounds == null) {
			throw new WrongUsageException("You didn't select a region with your wand.");
		}

		int ix = bounds[0];
		int iy = bounds[1] - value;
		int iz = bounds[2];
		int ax = bounds[3];
		int ay = bounds[4] + value;
		int az = bounds[5];

		WandItem.setBounds(player, ix, iy, iz, ax, ay, az);
		return;
	} else {
		throw new WrongUsageException("Missing parameters! /tc_wand expand <val>");
	}
}
 
開發者ID:tiffit,項目名稱:TaleCraft,代碼行數:23,代碼來源:WandCommand.java

示例11: execute

import net.minecraft.command.CommandBase; //導入依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	// Pattern Matching?
	// 0 1 -> [strength]
	// 1 2 -> <entity> [strength]
	// 3 4 -> <x> <y> <z> [strength]


	// entities = PlayerSelector.matchEntities(sender, args[0], Entity.class);

	//		if(args.length != 3) {
	//			throw new CommandException("Wrong number of parameters: " + args.length + " given, 3 needed.");
	//		}

	{
		BlockPos originPos = sender.getPosition();
		CoordinateArg posX = CommandBase.parseCoordinate(originPos.getX(), args[0], false);
		CoordinateArg posY = CommandBase.parseCoordinate(originPos.getY(), args[1], false);
		CoordinateArg posZ = CommandBase.parseCoordinate(originPos.getZ(), args[2], false);
		BlockPos pos = new BlockPos(posX.getAmount(), posY.getAmount(), posZ.getAmount());
		
		sender.getEntityWorld().createExplosion(null, pos.getX(), pos.getY(), pos.getZ(), 10f, false);
	}
}
 
開發者ID:tiffit,項目名稱:TaleCraft,代碼行數:25,代碼來源:ExplosionCommand.java

示例12: execute

import net.minecraft.command.CommandBase; //導入依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	if(args.length != 6) {
		throw new CommandException("Wrong number of parameters: " + args.length + " given, 6 needed.");
	}

	BlockPos originPos = sender.getPosition();

	CoordinateArg minX = CommandBase.parseCoordinate(originPos.getX(), args[0], false);
	CoordinateArg minY = CommandBase.parseCoordinate(originPos.getY(), args[1], false);
	CoordinateArg minZ = CommandBase.parseCoordinate(originPos.getZ(), args[2], false);
	CoordinateArg maxX = CommandBase.parseCoordinate(originPos.getX(), args[3], false);
	CoordinateArg maxY = CommandBase.parseCoordinate(originPos.getY(), args[4], false);
	CoordinateArg maxZ = CommandBase.parseCoordinate(originPos.getZ(), args[5], false);

	int ix = Math.min((int)minX.getAmount(), (int)maxX.getAmount());
	int iy = Math.min((int)minY.getAmount(), (int)maxY.getAmount());
	int iz = Math.min((int)minZ.getAmount(), (int)maxZ.getAmount());
	int ax = Math.max((int)minX.getAmount(), (int)maxX.getAmount());
	int ay = Math.max((int)minY.getAmount(), (int)maxY.getAmount());
	int az = Math.max((int)minZ.getAmount(), (int)maxZ.getAmount());

	Invoke.trigger(new CommandSenderInvokeSource(sender), ix, iy, iz, ax, ay, az, EnumTriggerState.ON);
}
 
開發者ID:tiffit,項目名稱:TaleCraft,代碼行數:25,代碼來源:RegionTriggerCommand.java

示例13: addTabCompletionOptions

import net.minecraft.command.CommandBase; //導入依賴的package包/類
@Override
public List addTabCompletionOptions(ICommandSender commandSender, String[] args)
{
	if (args.length == 1)
	{
		return getListOfStringsFromIterableMatchingLastWord(args, commands);
	} else if (args.length >= 2)
	{
		for (CommandBase command : subCommands)
		{
			if (command.getCommandName().equalsIgnoreCase(args[0]))
			{
				return command.addTabCompletionOptions(commandSender, args);
			}
		}
	}

	return null;
}
 
開發者ID:Rotatceps,項目名稱:EE3Helper,代碼行數:20,代碼來源:CommandEE3H.java

示例14: processCommand

import net.minecraft.command.CommandBase; //導入依賴的package包/類
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
	if (args.length != 4 || (!("add").equals(args[1]) && !("set").equals(args[1])) || (!("current").equals(args[2]) && !("max").equals(args[2]))) {
		throw new WrongUsageException(getCommandUsage(sender));
	}
	EntityPlayerMP commandSender = CommandBase.getCommandSenderAsPlayer(sender);
	EntityPlayerMP player = CommandBase.getPlayer(sender, args[0]);
	ZSSPlayerInfo info = ZSSPlayerInfo.get(player);
	boolean max = ("max").equals(args[2]);
	boolean add = ("add").equals(args[1]);
	int mp = CommandBase.parseInt(args[3]);
	if (mp < 0 && !add) {
		throw new CommandException("commands.zssmagic.negative", args[2]);
	}
	if (add) {
		mp += (max ? info.getMaxMagic() : info.getCurrentMagic());
	}
	if (max) {
		info.setMaxMagic(mp);
		mp = Math.round(info.getMaxMagic());
	} else {
		info.setCurrentMagic(mp);
		mp = Math.round(info.getCurrentMagic());
	}
	PlayerUtils.sendTranslatedChat(commandSender, "commands.zssmagic.success", player.getName(), args[2], mp);
}
 
開發者ID:coolAlias,項目名稱:ZeldaSwordSkills,代碼行數:27,代碼來源:CommandSetMagic.java

示例15: func_71558_b

import net.minecraft.command.CommandBase; //導入依賴的package包/類
public List func_71558_b(ICommandSender p_71558_1_, String p_71558_2_) {
   String[] var3 = p_71558_2_.split(" ", -1);
   String var4 = var3[0];
   if(var3.length == 1) {
      ArrayList var8 = new ArrayList();
      Iterator var6 = this.field_71562_a.entrySet().iterator();

      while(var6.hasNext()) {
         Entry var7 = (Entry)var6.next();
         if(CommandBase.func_71523_a(var4, (String)var7.getKey()) && ((ICommand)var7.getValue()).func_71519_b(p_71558_1_)) {
            var8.add(var7.getKey());
         }
      }

      return var8;
   } else {
      if(var3.length > 1) {
         ICommand var5 = (ICommand)this.field_71562_a.get(var4);
         if(var5 != null) {
            return var5.func_71516_a(p_71558_1_, func_71559_a(var3));
         }
      }

      return null;
   }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:27,代碼來源:CommandHandler.java


注:本文中的net.minecraft.command.CommandBase類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。