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

The following examples show how to use net.minecraft.entity.player.EntityPlayer#addExperience() . 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 check out the related API usage on the sidebar.
Example 1
Source File: ItemExpCapsule.java    From Cyberware with MIT License 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
	if (!playerIn.capabilities.isCreativeMode)
	{
		--stack.stackSize;
	}
	
	int xp = 0;
	if (stack.hasTagCompound())
	{
		NBTTagCompound c = stack.getTagCompound();
		if (c.hasKey("xp"))
		{
			xp = c.getInteger("xp");
		}
	}
	
	playerIn.addExperience(xp);
	
	return new ActionResult(EnumActionResult.SUCCESS, stack);
}
 
Example 2
Source File: TileEntityAerialInterface.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){
    if(resource != null && canFill(from, resource.getFluid())) {
        EntityPlayer player = getPlayer();
        if(player != null) {
            int liquidToXP = PneumaticCraftAPIHandler.getInstance().liquidXPs.get(resource.getFluid());
            int xpPoints = resource.amount / liquidToXP;
            if(doFill) {
                player.addExperience(xpPoints);
                curXpFluid = resource.getFluid();
            }
            return xpPoints * liquidToXP;
        }
    }
    return 0;
}
 
Example 3
Source File: DataHelper.java    From GokiStats with MIT License 4 votes vote down vote up
public static void setPlayersExpTo(EntityPlayer player, int total) {
    player.experience = 0;
    player.experienceLevel = 0;
    player.experienceTotal = 0;
    player.addExperience(total);
}