本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.addExperience方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.addExperience方法的具体用法?Java EntityPlayer.addExperience怎么用?Java EntityPlayer.addExperience使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.addExperience方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fill
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public int fill(FluidStack resource, boolean doFill) {
if (resource != null && canFill(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;
}
示例2: onRightClickBlock
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClickBlock(RightClickBlock event)
{
if(!(event.getWorld().getBlockState(event.getPos()).getBlock() instanceof XPBlock) || event.getHand() != EnumHand.MAIN_HAND)
return;
if(!event.getWorld().isRemote)
{
if(event.getEntityPlayer().isSneaking()) //sneaking = add all player XP to the block
{
((TileEntityXPBlock)event.getWorld().getTileEntity(event.getPos())).addXP(event.getEntityPlayer().experienceTotal);
event.getEntityPlayer().addExperienceLevel(-event.getEntityPlayer().experienceLevel - 1); // set player XP to 0
}
else //not sneaking = remove exactly enough XP from the block to get player to the next level
{
TileEntityXPBlock te = ((TileEntityXPBlock)event.getWorld().getTileEntity(event.getPos()));
EntityPlayer player = event.getEntityPlayer();
int neededXP = player.xpBarCap() - (int)player.experience;
int availableXP = te.removeXP(neededXP);
player.addExperience(availableXP);
}
}
}
示例3: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn){
if (!playerIn.world.isRemote) {
playerIn.inventory.addItemStackToInventory(new ItemStack(ModItems.emptytincan, 1));
playerIn.addExperience(1);
playerIn.getHeldItem(handIn).shrink(1);
ItemStack random_item = new ItemStack(loot_table[(int) (Math.random() * loot_table.length)], 1);
playerIn.inventory.addItemStackToInventory(random_item);
}
return super.onItemRightClick(worldIn, playerIn, handIn);
}
示例4: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand handIn, EnumFacing facing, float hitX, float hitY, float hitZ){
playerIn.inventory.addItemStackToInventory(new ItemStack(ModItems.brokentoothbrush,1));
playerIn.addExperience(1);
playerIn.getHeldItem(handIn).shrink(1);
return super.onItemUse(playerIn, worldIn, pos, handIn, facing, hitX, hitY, hitZ);
}
示例5: onCollideWithPlayer
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer entityIn)
{
if (!this.worldObj.isRemote)
{
if (this.delayBeforeCanPickup == 0 && entityIn.xpCooldown == 0)
{
entityIn.xpCooldown = 2;
this.worldObj.playSoundAtEntity(entityIn, "random.orb", 0.1F, 0.5F * ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.8F));
entityIn.onItemPickup(this, 1);
entityIn.addExperience(this.xpValue);
this.setDead();
}
}
}
示例6: onCollideWithPlayer
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer entityIn)
{
if (!this.world.isRemote)
{
if (this.delayBeforeCanPickup == 0 && entityIn.xpCooldown == 0)
{
entityIn.xpCooldown = 2;
entityIn.onItemPickup(this, 1);
ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, entityIn);
if (!itemstack.func_190926_b() && itemstack.isItemDamaged())
{
int i = Math.min(this.xpToDurability(this.xpValue), itemstack.getItemDamage());
this.xpValue -= this.durabilityToXp(i);
itemstack.setItemDamage(itemstack.getItemDamage() - i);
}
if (this.xpValue > 0)
{
entityIn.addExperience(this.xpValue);
}
this.setDead();
}
}
}
示例7: onCollideWithPlayer
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer entityIn)
{
if (!this.worldObj.isRemote)
{
if (this.delayBeforeCanPickup == 0 && entityIn.xpCooldown == 0)
{
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerPickupXpEvent(entityIn, this))) return;
entityIn.xpCooldown = 2;
this.worldObj.playSound((EntityPlayer)null, entityIn.posX, entityIn.posY, entityIn.posZ, SoundEvents.ENTITY_EXPERIENCE_ORB_TOUCH, SoundCategory.PLAYERS, 0.1F, 0.5F * ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.8F));
entityIn.onItemPickup(this, 1);
ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, entityIn);
if (itemstack != null && itemstack.isItemDamaged())
{
int i = Math.min(this.xpToDurability(this.xpValue), itemstack.getItemDamage());
this.xpValue -= this.durabilityToXp(i);
itemstack.setItemDamage(itemstack.getItemDamage() - i);
}
if (this.xpValue > 0)
{
entityIn.addExperience(this.xpValue);
}
this.setDead();
}
}
}
示例8: updateXP
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void updateXP(EntityPlayer player, int op, int xp) {
int exp;
XPCapability cap = player.getCapability(XPBox.XP_CAPABILITY, null);
switch (op) {
case MessageOp.WITHDRAW:
if (xp > cap.value)
xp = cap.value;
if (0 == xp)
break;
player.addExperience(xp);
cap.value -= xp;
break;
case MessageOp.DEPOSIT:
exp = getTotalXP(player);
if (xp > exp)
break;
if (xp + cap.value > GuiXPBox.MAX)
xp = GuiXPBox.MAX - cap.value;
if (0 == xp)
break;
player.experience = 0;
player.experienceLevel = 0;
player.experienceTotal = 0;
player.addExperience(exp - xp);
cap.value += xp;
break;
case MessageOp.SETLEVEL:
exp = getTotalXP(player);
if (exp + cap.value < exp)
exp = Integer.MAX_VALUE;
else
exp += cap.value;
if (0 == exp)
break;
player.experience = 0;
player.experienceLevel = 0;
player.experienceTotal = 0;
for (int lv = 0; lv < xp; ++lv) {
int t = xpBarCap(lv);
if (exp >= t) {
exp -= t;
player.addExperience(t);
} else {
player.addExperience(exp);
exp = 0;
break;
}
}
if (exp > GuiXPBox.MAX)
exp = GuiXPBox.MAX;
cap.value = exp;
break;
}
sendXPMessage(player);
}
示例9: processCommand
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* 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()});
}
}
}
示例10: execute
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* 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()});
}
}
}
示例11: setExperiencePoints
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void setExperiencePoints(EntityPlayer player, int amount) {
player.experienceLevel = 0;
player.experience = 0;
player.addExperience(amount);
}