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

The following examples show how to use net.minecraft.entity.player.EntityPlayer#addExperienceLevel() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
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);
	if (worldServer == null || worldServer.getMinecraftServer() == null) { // Dimension doesn't exist
		throw new IllegalArgumentException("Dimension: " + dimension + " doesn't exist!");
	}
	worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, dimension, new GTCommandTeleporter(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
public static void teleportToDimension(EntityPlayer player, int dimension, double x, double y, double z) {
	if (!(player instanceof EntityPlayerMP)) return;
	int oldDimension = player.world.provider.getDimension();
	EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player;
	MinecraftServer server = ((EntityPlayerMP) player).world.getMinecraftServer();
	if (server == null) return;
	WorldServer worldServer = server.getWorld(dimension);
	player.addExperienceLevel(0);

	if (worldServer.getMinecraftServer() == null) return;

	worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, dimension, new CustomTeleporter(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
Source Project: Et-Futurum   File: ContainerEnchantment.java    License: The Unlicense 4 votes vote down vote up
private static void chargeForEnchant(EntityPlayer player, Random rand, int amount) {
	player.addExperienceLevel(-amount);

	setEnchantSeed(player, rand.nextInt());
}