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


Java CommandBase.parseInt方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: getLocation

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
public static Coord getLocation(ICommandContext context, List<String> args) throws NumberInvalidException, PlayerNotFoundException{
	ArgumentParser ap = new ArgumentParser(args);

	Coord pos = context.getPos();
	
	if(ap.match(0, "here") || ap.match(0, "nearby")){
		return new Coord((int) pos.getX(), 0, (int) pos.getZ());
	} else {
		try {
			int x = CommandBase.parseInt(ap.get(0));
			int z = CommandBase.parseInt(ap.get(1));
			return new Coord(x, 0, z);
		} catch (NumberInvalidException e) {
			context.sendMessage("Failure: Invalid Coords: X Z", MessageType.ERROR);
			throw(e);
		}
	}
}
 
開發者ID:Greymerk,項目名稱:minecraft-roguelike,代碼行數:19,代碼來源:CommandRouteDungeon.java

示例6: pontuslevel

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@HarshenCommand
public static void pontuslevel(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
	EntityPlayer player = args.length == 1 ? CommandBase.getCommandSenderAsPlayer(sender) : CommandBase.getPlayer(server, sender, args[0]);
	String rawInt = args[args.length == 1 ? 0 : 1];
	int i = CommandBase.parseInt(rawInt);
	player.getEntityData().setInteger("PontusBiomeLevel", i);
	HarshenNetwork.sendToPlayer(player, new MessagePacketPlayerHasAccess(player));
	HandlerPontusAllowed.setAllowed(player, i);
	message(sender, "success", player.getName(), i);
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:12,代碼來源:HarshenCastleCommands.java

示例7: executeCommand

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public void executeCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    String filename = args[0];
    int tick = CommandBase.parseInt(args[1], 0);
    Record record = CommandRecord.getRecord(filename);

    if (tick < 0 || tick >= record.actions.size())
    {
        throw new CommandException("record.tick_out_range", tick, record.actions.size() - 1);
    }

    this.removeActions(args, record, tick);
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:15,代碼來源:SubCommandRecordRemove.java

示例8: removeActions

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
/**
 * Remove action(s) from given record at given tick
 */
private void removeActions(String[] args, Record record, int tick) throws CommandException
{
    if (args.length > 2)
    {
        int index = CommandBase.parseInt(args[2]);
        List<Action> actions = record.actions.get(tick);

        if (actions == null)
        {
            throw new CommandException("record.already_empty", args[1], args[0]);
        }

        if (index < 0 && index >= actions.size())
        {
            throw new CommandException("record.index_out_range", index, actions.size() - 1);
        }

        /* Remove action at given tick */
        if (actions.size() <= 1)
        {
            record.actions.set(tick, null);
        }
        else
        {
            actions.remove(index);
        }
    }
    else
    {
        /* Remove all actions at tick */
        record.actions.set(tick, null);
    }

    record.dirty = true;
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:39,代碼來源:SubCommandRecordRemove.java

示例9: executeCommand

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public void executeCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    String filename = args[0];
    int tick = CommandBase.parseInt(args[1], 0);
    Record record = CommandRecord.getRecord(filename);

    if (tick < 0 || tick >= record.actions.size())
    {
        throw new CommandException("record.tick_out_range", tick);
    }

    if (!Action.TYPES.containsKey(args[2]))
    {
        throw new CommandException("record.wrong_action", args[2]);
    }

    try
    {
        Action action = Action.fromType(Action.TYPES.get(args[2]).byteValue());

        if (args.length > 3)
        {
            action.fromNBT(JsonToNBT.getTagFromJson(CommandMorph.mergeArgs(args, 3)));
        }

        record.addAction(tick, action);
        record.dirty = true;
    }
    catch (Exception e)
    {
        throw new CommandException("record.add", args[2], e.getMessage());
    }
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:35,代碼來源:SubCommandRecordAdd.java

示例10: execute

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
public static void execute(CommandJED cmd, int dimension, String[] args, ICommandSender sender) throws CommandException
{
    World world = DimensionManager.getWorld(dimension);

    if (world != null)
    {
        BlockPos pos = null;

        if (args.length == 0)
        {
            pos = sender instanceof EntityPlayer ? ((EntityPlayer) sender).getPosition() : null;
        }
        else if (args.length == 3)
        {
            pos = new BlockPos(CommandBase.parseInt(args[0]), CommandBase.parseInt(args[1]), CommandBase.parseInt(args[2]));
        }
        else if (args.length == 1 && args[0].equals("query"))
        {
            pos = world.getSpawnPoint();
            sender.sendMessage(new TextComponentTranslation("jed.commands.setworldspawn.query",
                    Integer.valueOf(dimension), Integer.valueOf(pos.getX()), Integer.valueOf(pos.getY()), Integer.valueOf(pos.getZ())));
            return;
        }

        if (pos != null)
        {
            world.setSpawnPoint(pos);
            CommandBase.notifyCommandListener(sender, cmd, "jed.commands.setworldspawn.success",
                    Integer.valueOf(dimension), Integer.valueOf(pos.getX()), Integer.valueOf(pos.getY()), Integer.valueOf(pos.getZ()));
        }
        else
        {
            CommandJED.throwUsage("setworldspawn");
        }
    }
    else
    {
        CommandJED.throwNumber("dimension.notloaded", Integer.valueOf(dimension));
    }
}
 
開發者ID:maruohon,項目名稱:justenoughdimensions,代碼行數:41,代碼來源:CommandJEDSetWorldSpawn.java

示例11: execute_expand_into

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
private void execute_expand_into(String[] args, EntityPlayerMP player, ICommandSender sender) throws CommandException {
	if(args.length == 3) {
		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];
		int iz = bounds[2];
		int ax = bounds[3];
		int ay = bounds[4];
		int az = bounds[5];

		int direction = parseDirection(args[1], player);
		int value = CommandBase.parseInt(args[2], 1, 128);

		switch (direction) {
		case 0: ay += value; break; // +y
		case 1: iy -= value; break; // -y
		case 2: iz -= value; break; // -z
		case 3: ax += value; break; // +x
		case 4: az += value; break; // +z
		case 5: ix -= value; break; // -x
		default: throw new WrongUsageException("Direction unknown: " + args[2]);
		}

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

示例12: execute

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	if(args.length != 1) {
		return;
	}

	int snap = CommandBase.parseInt(args[0], 0, 64) + 1;
	ClientProxy.settings.setInteger("item.paste.snap", snap);
	ClientProxy.settings.send();
}
 
開發者ID:tiffit,項目名稱:TaleCraft,代碼行數:11,代碼來源:PasteSnapCommand.java

示例13: execute

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	if(args.length != 1) {
		return;
	}

	int reach = CommandBase.parseInt(args[0], 1, 64);
	ClientProxy.settings.setInteger("item.paste.reach", reach);
	ClientProxy.settings.send();
}
 
開發者ID:tiffit,項目名稱:TaleCraft,代碼行數:11,代碼來源:PasteReachCommand.java

示例14: execute

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public void execute(ICommandContext context, List<String> args) {
	
	ArgumentParser ap = new ArgumentParser(args);
	
	IWorldEditor editor = context.createEditor();
	Coord pos;
	if(!ap.hasEntry(0)){
		pos = context.getPos();
	} else {
		int x; int z;
		try {
			x = CommandBase.parseInt(ap.get(0));
			z = CommandBase.parseInt(ap.get(1));
		} catch (NumberInvalidException e) {
			context.sendMessage("Failure: Invalid Coords: X Z", MessageType.ERROR);
			return;
		}
		pos = new Coord(x, 0, z);
	}
	
	context.sendMessage("Biome Information for " + pos.toString(), MessageType.SPECIAL);
	
	Biome biome = editor.getInfo(pos).getBiome();
	context.sendMessage(biome.getBiomeName(), MessageType.SPECIAL);
	
	Set<BiomeDictionary.Type> biomeTypes = BiomeDictionary.getTypes(biome);
	String types = "";
	for(BiomeDictionary.Type type : biomeTypes){
		types += type.getName() + " ";
	}
	
	context.sendMessage(types, MessageType.SPECIAL);
	return;
}
 
開發者ID:Greymerk,項目名稱:minecraft-roguelike,代碼行數:36,代碼來源:CommandRouteBiome.java

示例15: processCommand

import net.minecraft.command.CommandBase; //導入方法依賴的package包/類
@Override
public void processCommand(ICommandSender icommandsender, String[] astring)
{
    EntityPlayerMP playerBase;

    if (astring.length > 1)
    {
        throw new WrongUsageException("Too many command arguments! Usage: " + this.getCommandUsage(icommandsender), new Object[0]);
    }
    else
    {
        try
        {
            playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(icommandsender.getCommandSenderName(), true);

            if (playerBase != null)
            {
                int dimID;

                if (astring.length == 0)
                {
                    dimID = playerBase.dimension;
                }
                else
                {
                	try {
                		dimID = CommandBase.parseInt(icommandsender, astring[0]);
                	} catch (Exception e) { throw new WrongUsageException("Needs a dimension number! Usage: " + this.getCommandUsage(icommandsender), new Object[0]); }
                }

                if (ConfigManagerCore.setLoaded(dimID))
                {
                    playerBase.addChatMessage(new ChatComponentText("[GCKeepLoaded] Successfully set dimension " + dimID + " to load staticly"));
                }
                else
                {
                    if (ConfigManagerCore.setUnloaded(dimID))
                    {
                        playerBase.addChatMessage(new ChatComponentText("[GCKeepLoaded] Successfully set dimension " + dimID + " to not load staticly"));
                    }
                    else
                    {
                        playerBase.addChatMessage(new ChatComponentText("[GCKeepLoaded] Failed to set dimension as not static"));
                    }
                }
            }
        }
        catch (final Exception var6)
        {
            throw new CommandException(var6.getMessage(), new Object[0]);
        }
    }
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:54,代碼來源:CommandKeepDim.java


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