Search in sources :

Example 51 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project ArsMagica2 by Mithion.

the class RecoverKeystoneCommand method processCommand.

@Override
public void processCommand(ICommandSender icommandsender, String[] astring) {
    if (astring.length != 1 && astring.length != 0) {
        throw new WrongUsageException(this.getCommandUsage(icommandsender), new Object[0]);
    }
    EntityPlayer player = null;
    if (astring.length == 2) {
        player = getPlayer(icommandsender, astring[0]);
    } else {
        player = getCommandSenderAsPlayer(icommandsender);
    }
    if (player == null)
        return;
    ExtendedProperties.For(player).isRecoveringKeystone = true;
    func_152373_a(icommandsender, this, player.getCommandSenderName() + " is recovering a Keystone combination.", new Object[0]);
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 52 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project BiomesOPlenty by Glitchfiend.

the class BOPCommand method teleportFoundBiome.

private void teleportFoundBiome(ICommandSender sender, String[] args) throws CommandException {
    if (args.length < 2) {
        throw new WrongUsageException("commands.biomesoplenty.tpbiome.usage");
    }
    // Parse args[1] to find the biome to search for - search for a string matching the biome identifier, or an integer matching the biome id
    Biome biomeToFind = null;
    if (biomeToFind == null) {
        try {
            int biomeId = parseInt(args[1], 0, 255);
            biomeToFind = Biome.getBiome(biomeId);
        } catch (NumberInvalidException e) {
            biomeToFind = BiomeUtils.getBiomeForLoc(new ResourceLocation(args[1]));
        }
    }
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);
    World world = player.world;
    BlockPos closestBiomePos = biomeToFind == null ? null : BiomeUtils.spiralOutwardsLookingForBiome(world, biomeToFind, player.posX, player.posZ);
    String biomeName = biomeToFind != null && FMLCommonHandler.instance().getSide() == Side.CLIENT ? biomeToFind.getBiomeName() : "Undefined";
    if (closestBiomePos != null) {
        double x = (double) closestBiomePos.getX();
        double y = (double) world.getTopSolidOrLiquidBlock(closestBiomePos).getY();
        double z = (double) closestBiomePos.getZ();
        player.connection.setPlayerLocation(x, y, z, player.rotationYaw, player.rotationPitch);
        sender.sendMessage(new TextComponentTranslation("commands.biomesoplenty.tpbiome.success", player.getName(), biomeName, x, y, z));
    } else {
        sender.sendMessage(new TextComponentTranslation("commands.biomesoplenty.tpbiome.error", biomeName));
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Biome(net.minecraft.world.biome.Biome) ResourceLocation(net.minecraft.util.ResourceLocation) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos) NumberInvalidException(net.minecraft.command.NumberInvalidException) World(net.minecraft.world.World)

Example 53 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project BiomesOPlenty by Glitchfiend.

the class BOPCommand method getBiomeName.

private void getBiomeName(ICommandSender sender, String[] args) throws CommandException {
    if (args.length < 2) {
        throw new WrongUsageException("commands.biomesoplenty.biomename.usage");
    }
    int biomeId = parseInt(args[1], 0, 255);
    Biome biome = Biome.getBiome(biomeId);
    sender.sendMessage(new TextComponentTranslation("commands.biomesoplenty.biomename.success", biomeId, biome == null ? "Undefined" : biome.getBiomeName()));
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Biome(net.minecraft.world.biome.Biome)

Example 54 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project BiomesOPlenty by Glitchfiend.

the class BOPCommand method stripChunk.

private void stripChunk(ICommandSender sender, String[] args) throws CommandException {
    if (args.length < 5) {
        throw new WrongUsageException("commands.biomesoplenty.stripchunk.usage");
    }
    int radius = parseInt(args[1]);
    String mode = args[2];
    boolean blacklist;
    if (mode.equals("include"))
        blacklist = false;
    else if (mode.equals("exclude"))
        blacklist = true;
    else {
        throw new WrongUsageException("commands.biomesoplenty.stripchunk.usage");
    }
    List<IBlockState> stateList = Lists.newArrayList();
    for (int i = 0; i < (args.length - 3) / 2; i++) {
        Block block = getBlockByText(sender, args[i * 2 + 3]);
        int metadata = parseInt(args[i * 2 + 3 + 1]);
        stateList.add(block.getStateFromMeta(metadata));
    }
    BlockPos playerPos = sender.getPosition();
    World world = sender.getEntityWorld();
    int playerChunkX = playerPos.getX() >> 4;
    int playerChunkZ = playerPos.getZ() >> 4;
    for (int chunkX = -radius; chunkX < radius; chunkX++) {
        for (int chunkZ = -radius; chunkZ < radius; chunkZ++) {
            Chunk chunk = world.getChunkFromChunkCoords(playerChunkX + chunkX, (playerChunkZ + chunkZ));
            for (ExtendedBlockStorage blockStorage : chunk.getBlockStorageArray()) {
                if (blockStorage != null) {
                    for (int x = 0; x < 16; x++) {
                        for (int y = 0; y < 16; y++) {
                            for (int z = 0; z < 16; z++) {
                                BlockPos pos = new BlockPos(chunk.x * 16 + x, blockStorage.getYLocation() + y, chunk.z * 16 + z);
                                IBlockState state = blockStorage.get(x, y, z);
                                if (((!blacklist && stateList.contains(state)) || (blacklist && !stateList.contains(state))) && pos.getY() > 0) {
                                    blockStorage.set(x, y, z, Blocks.AIR.getDefaultState());
                                    world.notifyBlockUpdate(pos, state, Blocks.AIR.getDefaultState(), 3);
                                    world.notifyNeighborsRespectDebug(pos, Blocks.AIR, false);
                                }
                            }
                        }
                    }
                }
            }
            chunk.generateSkylightMap();
        }
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Chunk(net.minecraft.world.chunk.Chunk) ExtendedBlockStorage(net.minecraft.world.chunk.storage.ExtendedBlockStorage)

Example 55 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project Armourers-Workshop by RiskyKen.

the class CommandClearSkins method processCommand.

@Override
public void processCommand(ICommandSender commandSender, String[] currentCommand) {
    if (currentCommand.length != 2) {
        throw new WrongUsageException(getCommandUsage(commandSender), (Object) currentCommand);
    }
    String playerName = currentCommand[1];
    EntityPlayerMP player = getPlayer(commandSender, playerName);
    if (player == null) {
        return;
    }
    ExPropsPlayerSkinData.get(player).clearAllEquipmentStacks();
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Aggregations

WrongUsageException (net.minecraft.command.WrongUsageException)63 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)28 CommandException (net.minecraft.command.CommandException)21 EntityPlayer (net.minecraft.entity.player.EntityPlayer)21 ItemStack (net.minecraft.item.ItemStack)11 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)8 ChatComponentText (net.minecraft.util.ChatComponentText)7 BlockPos (net.minecraft.util.math.BlockPos)6 MinecraftServer (net.minecraft.server.MinecraftServer)5 Entity (net.minecraft.entity.Entity)4 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)4 World (net.minecraft.world.World)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 Affinity (am2.api.spell.enums.Affinity)2 PlayerIdentifier (com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier)2 Color (java.awt.Color)2 File (java.io.File)2 List (java.util.List)2 SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)2 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)2