<commit_before>package com.lsc.player;

import java.util.Random;

import com.lsc.LootSlashConquer;
import com.lsc.capabilities.cap.CapabilityEnemyInfo;
import com.lsc.capabilities.implementation.EnemyInfo;
import com.lsc.capabilities.implementation.PlayerInformation;
import com.lsc.entities.EntityMonster;
import com.lsc.network.PacketUpdatePlayerInformation;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.play.server.SPacketTitle;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;

/**
 * 
 * @author TheXFactor117
 *
 */
public class ExperienceHelper 
{
	public static void addExperience(EntityPlayer player, PlayerInformation playerInfo, EntityLivingBase enemy)
	{
		int experience = 0;
		
		EnemyInfo enemyInfo = (EnemyInfo) enemy.getCapability(CapabilityEnemyInfo.ENEMY_INFO, null);
		
		// calculates how much experience a monster should drop
		// based on the level, tier, and rarity of the monster
		// ALL vanilla and non-LSC monsters have a rarity of 1.
		if (enemyInfo != null)
		{
			int enemyLevel = enemyInfo.getEnemyLevel();
			int enemyTier = enemyInfo.getEnemyTier();
			int rarity = 1;
			
			if (enemy instanceof EntityMonster)
			{
				rarity = EntityMonster.rarity;
			}
			
			// calculates the different multipliers and multiplies them together to get the total multiplier
			int tierMultiplier = (int) (Math.pow(enemyTier, 2.25) / 3 + 1);
			int rarityMultiplier = (int) (Math.pow(rarity, 1.75) / 2.5 + 1);
			int multiplier = (int) ((tierMultiplier * rarityMultiplier + 1) / 1.5);
			
			// base experience is 5 for now...
			// formula: 5 * (level+1 ^ 1.5) * multiplier
			experience = (int) (5 * (Math.pow(enemyLevel + 1, 1.5)) * multiplier);
		}
		
		// update experience on client AND server; increase level if need be.
		playerInfo.setPlayerExperience(playerInfo.getPlayerExperience() + experience);
		
		while (playerInfo.getPlayerExperience() > playerInfo.getLevelUpExperience(playerInfo.getPlayerLevel())) 
		{
			int leftOverExperience = playerInfo.getPlayerExperience() - playerInfo.getLevelUpExperience(playerInfo.getPlayerLevel());
			int skillPoints = 0;
			<commit_msg>Added actionbar message whenever you gain experience<commit_after>package com.lsc.player;

import java.util.Random;

import com.lsc.LootSlashConquer;
import com.lsc.capabilities.cap.CapabilityEnemyInfo;
import com.lsc.capabilities.implementation.EnemyInfo;
import com.lsc.capabilities.implementation.PlayerInformation;
import com.lsc.entities.EntityMonster;
import com.lsc.network.PacketUpdatePlayerInformation;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.play.server.SPacketTitle;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;

/**
 * 
 * @author TheXFactor117
 *
 */
public class ExperienceHelper 
{
	public static void addExperience(EntityPlayer player, PlayerInformation playerInfo, EntityLivingBase enemy)
	{
		int experience = 0;
		
		EnemyInfo enemyInfo = (EnemyInfo) enemy.getCapability(CapabilityEnemyInfo.ENEMY_INFO, null);
		
		// calculates how much experience a monster should drop
		// based on the level, tier, and rarity of the monster
		// ALL vanilla and non-LSC monsters have a rarity of 1.
		if (enemyInfo != null)
		{
			int enemyLevel = enemyInfo.getEnemyLevel();
			int enemyTier = enemyInfo.getEnemyTier();
			int rarity = 1;
			
			if (enemy instanceof EntityMonster)
			{
				rarity = EntityMonster.rarity;
			}
			
			// calculates the different multipliers and multiplies them together to get the total multiplier
			int tierMultiplier = (int) (Math.pow(enemyTier, 2.25) / 3 + 1);
			int rarityMultiplier = (int) (Math.pow(rarity, 1.75) / 2.5 + 1);
			int multiplier = (int) ((tierMultiplier * rarityMultiplier + 1) / 1.5);
			
			// base experience is 5 for now...
			// formula: 5 * (level+1 ^ 1.5) * multiplier
			experience = (int) (5 * (Math.pow(enemyLevel + 1, 1.5)) * multiplier);
		}
		
		// update experience on client AND server; increase level if need be.
		playerInfo.setPlayerExperience(playerInfo.getPlayerExperience() + experience);
		
		// Minecraft bug with actionbar times - it doesn't actually handle specifying times for the actionbar.
		SPacketTitle packetActionbar = new SPacketTitle(SPacketTitle.Type.ACTIONBAR, new TextComponentString("You killed " + enemy.getName() + " and gained " + experience + " experience!"), -1, -1, -1);
		((EntityPlayerMP) player).connection.sendPacket(packetActionbar);
		
		while (playerInfo.getPlayerExperience() > playerInfo.getLevelUpExperience(playerInfo.getPlayerLevel())) 
		{
			int leftOverExperience = playerInfo.getPlayerExperience() - playerInfo.getLevelUpExperience(playerInfo.getPlayerLevel());
			int skillPoints = 0;
			
{'fraction_non_alphanumeric': 0.10352335708630245, 'fraction_numerical': 0.012470308788598575, 'mean_word_length': 4.410064239828694, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '670378', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1530, 'n_words': 383}