Java Code Examples for net.minecraft.entity.player.EntityPlayer.addExperienceLevel()

The following are Jave code examples for showing how to use addExperienceLevel() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: tp-plus   File: CommandTPP.java   View Source Code Vote up 6 votes
public static void teleportToDimension(EntityPlayer player, int dimension, double x, double y, double z) {
    int oldDimension = player.getEntityWorld().provider.getDimension();
    EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player;
    MinecraftServer server = player.getEntityWorld().getMinecraftServer();
    WorldServer worldServer = server.getWorld(dimension);
    player.addExperienceLevel(0);


    worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, dimension, new RfToolsTeleporter(worldServer, x, y, z));
    player.setPositionAndUpdate(x, y, z);
    if (oldDimension == 1) {
        // For some reason teleporting out of the end does weird things.
        player.setPositionAndUpdate(x, y, z);
        worldServer.spawnEntity(player);
        worldServer.updateEntityWithOptionalForce(player, false);
    }
}
 
Example 2
Project: Whoosh   File: TeleportUtil.java   View Source Code Vote up 6 votes
public static void teleportToDimension(EntityPlayer player, int dimension, double x, double y, double z) {
    int oldDimension = player.getEntityWorld().provider.getDimension();
    EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player;
    MinecraftServer server = player.getEntityWorld().getMinecraftServer();
    WorldServer worldServer = server.getWorld(dimension);
    player.addExperienceLevel(0);


    worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, dimension, new WhooshTeleporter(worldServer, x, y, z));
    player.setPositionAndUpdate(x, y, z);
    if (oldDimension == 1) {
        // For some reason teleporting out of the end does weird things.
        player.setPositionAndUpdate(x, y, z);
        worldServer.spawnEntity(player);
        worldServer.updateEntityWithOptionalForce(player, false);
    }
}
 
Example 3
Project: DecompiledMinecraft   File: CommandXP.java   View Source Code Vote up 4 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length <= 0)
    {
        throw new WrongUsageException("commands.xp.usage", new Object[0]);
    }
    else
    {
        String s = args[0];
        boolean flag = s.endsWith("l") || s.endsWith("L");

        if (flag && s.length() > 1)
        {
            s = s.substring(0, s.length() - 1);
        }

        int i = parseInt(s);
        boolean flag1 = i < 0;

        if (flag1)
        {
            i *= -1;
        }

        EntityPlayer entityplayer = args.length > 1 ? getPlayer(sender, args[1]) : getCommandSenderAsPlayer(sender);

        if (flag)
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceLevel);

            if (flag1)
            {
                entityplayer.addExperienceLevel(-i);
                notifyOperators(sender, this, "commands.xp.success.negative.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
            else
            {
                entityplayer.addExperienceLevel(i);
                notifyOperators(sender, this, "commands.xp.success.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
        }
        else
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceTotal);

            if (flag1)
            {
                throw new CommandException("commands.xp.failure.widthdrawXp", new Object[0]);
            }

            entityplayer.addExperience(i);
            notifyOperators(sender, this, "commands.xp.success", new Object[] {Integer.valueOf(i), entityplayer.getName()});
        }
    }
}
 
Example 4
Project: DecompiledMinecraft   File: CommandXP.java   View Source Code Vote up 4 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length <= 0)
    {
        throw new WrongUsageException("commands.xp.usage", new Object[0]);
    }
    else
    {
        String s = args[0];
        boolean flag = s.endsWith("l") || s.endsWith("L");

        if (flag && s.length() > 1)
        {
            s = s.substring(0, s.length() - 1);
        }

        int i = parseInt(s);
        boolean flag1 = i < 0;

        if (flag1)
        {
            i *= -1;
        }

        EntityPlayer entityplayer = args.length > 1 ? getPlayer(sender, args[1]) : getCommandSenderAsPlayer(sender);

        if (flag)
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceLevel);

            if (flag1)
            {
                entityplayer.addExperienceLevel(-i);
                notifyOperators(sender, this, "commands.xp.success.negative.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
            else
            {
                entityplayer.addExperienceLevel(i);
                notifyOperators(sender, this, "commands.xp.success.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
        }
        else
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceTotal);

            if (flag1)
            {
                throw new CommandException("commands.xp.failure.widthdrawXp", new Object[0]);
            }

            entityplayer.addExperience(i);
            notifyOperators(sender, this, "commands.xp.success", new Object[] {Integer.valueOf(i), entityplayer.getName()});
        }
    }
}
 
Example 5
Project: BaseClient   File: CommandXP.java   View Source Code Vote up 4 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length <= 0)
    {
        throw new WrongUsageException("commands.xp.usage", new Object[0]);
    }
    else
    {
        String s = args[0];
        boolean flag = s.endsWith("l") || s.endsWith("L");

        if (flag && s.length() > 1)
        {
            s = s.substring(0, s.length() - 1);
        }

        int i = parseInt(s);
        boolean flag1 = i < 0;

        if (flag1)
        {
            i *= -1;
        }

        EntityPlayer entityplayer = args.length > 1 ? getPlayer(sender, args[1]) : getCommandSenderAsPlayer(sender);

        if (flag)
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceLevel);

            if (flag1)
            {
                entityplayer.addExperienceLevel(-i);
                notifyOperators(sender, this, "commands.xp.success.negative.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
            else
            {
                entityplayer.addExperienceLevel(i);
                notifyOperators(sender, this, "commands.xp.success.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
        }
        else
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceTotal);

            if (flag1)
            {
                throw new CommandException("commands.xp.failure.widthdrawXp", new Object[0]);
            }

            entityplayer.addExperience(i);
            notifyOperators(sender, this, "commands.xp.success", new Object[] {Integer.valueOf(i), entityplayer.getName()});
        }
    }
}
 
Example 6
Project: BaseClient   File: CommandXP.java   View Source Code Vote up 4 votes
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length <= 0)
    {
        throw new WrongUsageException("commands.xp.usage", new Object[0]);
    }
    else
    {
        String s = args[0];
        boolean flag = s.endsWith("l") || s.endsWith("L");

        if (flag && s.length() > 1)
        {
            s = s.substring(0, s.length() - 1);
        }

        int i = parseInt(s);
        boolean flag1 = i < 0;

        if (flag1)
        {
            i *= -1;
        }

        EntityPlayer entityplayer = args.length > 1 ? getPlayer(sender, args[1]) : getCommandSenderAsPlayer(sender);

        if (flag)
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceLevel);

            if (flag1)
            {
                entityplayer.addExperienceLevel(-i);
                notifyOperators(sender, this, "commands.xp.success.negative.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
            else
            {
                entityplayer.addExperienceLevel(i);
                notifyOperators(sender, this, "commands.xp.success.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
        }
        else
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceTotal);

            if (flag1)
            {
                throw new CommandException("commands.xp.failure.widthdrawXp", new Object[0]);
            }

            entityplayer.addExperience(i);
            notifyOperators(sender, this, "commands.xp.success", new Object[] {Integer.valueOf(i), entityplayer.getName()});
        }
    }
}
 
Example 7
Project: connor41-etfuturum2   File: ContainerEnchantment.java   View Source Code Vote up 4 votes
private static void chargeForEnchant(EntityPlayer player, Random rand, int amount) {
	player.addExperienceLevel(-amount);

	setEnchantSeed(player, rand.nextInt());
}
 
Example 8
Project: Backmemed   File: CommandXP.java   View Source Code Vote up 4 votes
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length <= 0)
    {
        throw new WrongUsageException("commands.xp.usage", new Object[0]);
    }
    else
    {
        String s = args[0];
        boolean flag = s.endsWith("l") || s.endsWith("L");

        if (flag && s.length() > 1)
        {
            s = s.substring(0, s.length() - 1);
        }

        int i = parseInt(s);
        boolean flag1 = i < 0;

        if (flag1)
        {
            i *= -1;
        }

        EntityPlayer entityplayer = args.length > 1 ? getPlayer(server, sender, args[1]) : getCommandSenderAsPlayer(sender);

        if (flag)
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceLevel);

            if (flag1)
            {
                entityplayer.addExperienceLevel(-i);
                notifyCommandListener(sender, this, "commands.xp.success.negative.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
            else
            {
                entityplayer.addExperienceLevel(i);
                notifyCommandListener(sender, this, "commands.xp.success.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
        }
        else
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceTotal);

            if (flag1)
            {
                throw new CommandException("commands.xp.failure.widthdrawXp", new Object[0]);
            }

            entityplayer.addExperience(i);
            notifyCommandListener(sender, this, "commands.xp.success", new Object[] {Integer.valueOf(i), entityplayer.getName()});
        }
    }
}
 
Example 9
Project: CustomWorldGen   File: CommandXP.java   View Source Code Vote up 4 votes
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length <= 0)
    {
        throw new WrongUsageException("commands.xp.usage", new Object[0]);
    }
    else
    {
        String s = args[0];
        boolean flag = s.endsWith("l") || s.endsWith("L");

        if (flag && s.length() > 1)
        {
            s = s.substring(0, s.length() - 1);
        }

        int i = parseInt(s);
        boolean flag1 = i < 0;

        if (flag1)
        {
            i *= -1;
        }

        EntityPlayer entityplayer = args.length > 1 ? getPlayer(server, sender, args[1]) : getCommandSenderAsPlayer(sender);

        if (flag)
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceLevel);

            if (flag1)
            {
                entityplayer.addExperienceLevel(-i);
                notifyCommandListener(sender, this, "commands.xp.success.negative.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
            else
            {
                entityplayer.addExperienceLevel(i);
                notifyCommandListener(sender, this, "commands.xp.success.levels", new Object[] {Integer.valueOf(i), entityplayer.getName()});
            }
        }
        else
        {
            sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, entityplayer.experienceTotal);

            if (flag1)
            {
                throw new CommandException("commands.xp.failure.widthdrawXp", new Object[0]);
            }

            entityplayer.addExperience(i);
            notifyCommandListener(sender, this, "commands.xp.success", new Object[] {Integer.valueOf(i), entityplayer.getName()});
        }
    }
}