本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.addStat方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.addStat方法的具体用法?Java EntityPlayer.addStat怎么用?Java EntityPlayer.addStat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.addStat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EXPERIENCE_BOTTLE_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
EntityExpBottle entityexpbottle = new EntityExpBottle(worldIn, playerIn);
entityexpbottle.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.7F, 1.0F);
worldIn.spawnEntityInWorld(entityexpbottle);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
示例2: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
if (!worldIn.capabilities.isCreativeMode)
{
itemstack.func_190918_g(1);
}
itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!itemStackIn.isRemote)
{
EntityEgg entityegg = new EntityEgg(itemStackIn, worldIn);
entityegg.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, 0.0F, 1.5F, 1.0F);
itemStackIn.spawnEntityInWorld(entityegg);
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
示例3: damageItem
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Damages the item in the ItemStack
*/
public void damageItem(int amount, EntityLivingBase entityIn)
{
if (!(entityIn instanceof EntityPlayer) || !((EntityPlayer)entityIn).capabilities.isCreativeMode)
{
if (this.isItemStackDamageable())
{
if (this.attemptDamageItem(amount, entityIn.getRNG()))
{
entityIn.renderBrokenItemStack(this);
this.func_190918_g(1);
if (entityIn instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)entityIn;
entityplayer.addStat(StatList.getObjectBreakStats(this.item));
}
this.itemDamage = 0;
}
}
}
}
示例4: turnBottleIntoItem
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
protected ItemStack turnBottleIntoItem(ItemStack p_185061_1_, EntityPlayer player, ItemStack stack)
{
--p_185061_1_.stackSize;
player.addStat(StatList.getObjectUseStats(this));
if (p_185061_1_.stackSize <= 0)
{
return stack;
}
else
{
if (!player.inventory.addItemStackToInventory(stack))
{
player.dropItem(stack, false);
}
return p_185061_1_;
}
}
示例5: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
EntitySnowball entitysnowball = new EntitySnowball(worldIn, playerIn);
entitysnowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
worldIn.spawnEntityInWorld(entitysnowball);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
示例6: harvestBlock
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) {
if (!worldIn.isRemote && stack.getItem() instanceof ItemShears) {
player.addStat(StatList.getBlockStats(this));
spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this)));
} else {
super.harvestBlock(worldIn, player, pos, state, te, stack);
}
}
示例7: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
if (itemStackIn.isRemote)
{
return new ActionResult(EnumActionResult.PASS, itemstack);
}
else
{
if (worldIn.isRiding() && worldIn.getRidingEntity() instanceof EntityPig)
{
EntityPig entitypig = (EntityPig)worldIn.getRidingEntity();
if (itemstack.getMaxDamage() - itemstack.getMetadata() >= 7 && entitypig.boost())
{
itemstack.damageItem(7, worldIn);
if (itemstack.func_190926_b())
{
ItemStack itemstack1 = new ItemStack(Items.FISHING_ROD);
itemstack1.setTagCompound(itemstack.getTagCompound());
return new ActionResult(EnumActionResult.SUCCESS, itemstack1);
}
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.PASS, itemstack);
}
}
示例8: onBlockActivated
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
playerIn.displayGui(new BlockWorkbench.InterfaceCraftingTable(worldIn, pos));
playerIn.addStat(StatList.CRAFTING_TABLE_INTERACTION);
return true;
}
}
示例9: harvestBlock
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{
player.addStat(StatList.getBlockStats(this));
player.addExhaustion(0.005F);
if (this.canSilkHarvest() && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0)
{
spawnAsEntity(worldIn, pos, this.getSilkTouchDrop(state));
}
else
{
if (worldIn.provider.doesWaterVaporize())
{
worldIn.setBlockToAir(pos);
return;
}
int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
this.dropBlockAsItem(worldIn, pos, state, i);
Material material = worldIn.getBlockState(pos.down()).getMaterial();
if (material.blocksMovement() || material.isLiquid())
{
worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState());
}
}
}
示例10: onBlockActivated
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
if (ilockablecontainer != null)
{
playerIn.displayGUIChest(ilockablecontainer);
if (this.chestType == BlockChest.Type.BASIC)
{
playerIn.addStat(StatList.CHEST_OPENED);
}
else if (this.chestType == BlockChest.Type.TRAP)
{
playerIn.addStat(StatList.TRAPPED_CHEST_TRIGGERED);
}
}
return true;
}
}
示例11: onItemUseFinish
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Nonnull
@Override
public ItemStack onItemUseFinish(ItemStack stack, @Nullable World worldIn, EntityLivingBase entityLiving) {
if (entityLiving instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer)entityLiving;
entityplayer.getFoodStats().addStats(this, stack);
worldIn.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
this.onFoodEaten(stack, worldIn, entityplayer);
entityplayer.addStat(StatList.getObjectUseStats(this));
}
return new ItemStack(FCRItems.GLASS_BOTTLE);
}
示例12: onItemUseFinish
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
* the Item before the action is complete.
*/
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
if (entityLiving instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)entityLiving;
entityplayer.getFoodStats().addStats(this, stack);
worldIn.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
this.onFoodEaten(stack, worldIn, entityplayer);
entityplayer.addStat(StatList.getObjectUseStats(this));
}
stack.func_190918_g(1);
return stack;
}
示例13: onPickupFromSlot
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
if (stack.getItem() instanceof ItemPotion && stack.getItemDamage() > 0)
player.addStat(AchievementList.potion, 1);
super.onPickupFromSlot(player, stack);
}
示例14: onItemUseFinish
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entity) {
EntityPlayer player = entity instanceof EntityPlayer ? (EntityPlayer)entity : null;
if (player == null || !player.capabilities.isCreativeMode) {
stack.shrink(1);
}
if (player instanceof EntityPlayerMP) {
//Trigger advancements! (Protip: there are no advancements for this)
CriteriaTriggers.CONSUME_ITEM.trigger((EntityPlayerMP)player, stack);
}
if (!world.isRemote) {
apply(stack, entity);
}
if (player != null) {
player.addStat(StatList.getObjectUseStats(this));
}
if (player == null || !player.capabilities.isCreativeMode) {
//if (stack.isEmpty()) {
//return new ItemStack(ThermionicsItems.EMPTY_SPIRIT_BOTTLE);
//}
if (player != null) {
player.inventory.addItemStackToInventory(new ItemStack(ThermionicsItems.EMPTY_SPIRIT_BOTTLE));
}
}
return stack;
}
示例15: harvestBlock
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack)
{
if (false && !worldIn.isRemote && stack != null && stack.getItem() == Items.SHEARS) // Forge: Noop
{
player.addStat(StatList.getBlockStats(this));
spawnAsEntity(worldIn, pos, new ItemStack(Blocks.DEADBUSH, 1, 0));
}
else
{
super.harvestBlock(worldIn, player, pos, state, te, stack);
}
}