Java Code Examples for net.minecraft.entity.player.EntityPlayer#addStat()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#addStat() .
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 check out the related API usage on the sidebar.
Example 1
Source Project: TofuCraftReload File: DrinkSoymilkRamune.java License: MIT License | 6 votes |
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)); if (entityplayer instanceof EntityPlayerMP) { CriteriaTriggers.CONSUME_ITEM.trigger((EntityPlayerMP)entityplayer, stack); } } return new ItemStack(Items.GLASS_BOTTLE); }
Example 2
Source Project: TofuCraftReload File: ItemFukumame.java License: MIT License | 6 votes |
/** * Called when the equipped item is right clicked. */ public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); if (!playerIn.capabilities.isCreativeMode) { stack.damageItem(1, playerIn); } worldIn.playSound((EntityPlayer) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); playerIn.getCooldownTracker().setCooldown(this, 4); if (!worldIn.isRemote) { for (int i = 0; i < 6; i++) { EntityFukumame entityfukumame = new EntityFukumame(worldIn, playerIn); float d0 = (worldIn.rand.nextFloat() * 12.0F) - 6.0F; applyEffect(entityfukumame, stack); entityfukumame.shoot(playerIn, playerIn.rotationPitch,playerIn.rotationYaw + d0,0.0F, 1.5f, 1.0F); worldIn.spawnEntity(entityfukumame); } } playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack); }
Example 3
Source Project: TofuCraftReload File: BlockYuba.java License: MIT License | 6 votes |
@Override public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack) { player.addStat(StatList.getBlockStats(this), 1); player.addExhaustion(0.025F); if (this.canSilkHarvest(worldIn, pos, state, player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0) { this.dropYuba(worldIn, pos, state); } else { if (stack != null && OreDictionary.containsMatch(false, OreDictionary.getOres("stickWood"), new ItemStack(Items.STICK))) { this.dropYuba(worldIn, pos, state); } } }
Example 4
Source Project: ToroQuest File: EntityShopkeeper.java License: GNU General Public License v3.0 | 6 votes |
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack) { boolean flag = stack != null && stack.getItem() == Items.SPAWN_EGG; if (!flag && isEntityAlive() && !isTrading() && !isChild() && !player.isSneaking()) { if (!this.world.isRemote) { RepData rep = getReputation(player); if (rep.rep.equals(ReputationLevel.OUTCAST) || rep.rep.equals(ReputationLevel.ENEMY) || rep.rep.equals(ReputationLevel.VILLAIN)) { chat(player, "I WILL NOT TRADE WITH A " + rep.rep); } else { this.setCustomer(player); player.displayVillagerTradeGui(this); } } player.addStat(StatList.TALKED_TO_VILLAGER); return true; } else { return super.processInteract(player, hand); } }
Example 5
Source Project: TofuCraftReload File: EntityTofunian.java License: MIT License | 5 votes |
public boolean processInteract(EntityPlayer player, EnumHand hand) { ItemStack itemstack = player.getHeldItem(hand); boolean flag = itemstack.getItem() == Items.NAME_TAG; if (flag) { itemstack.interactWithEntity(player, this, hand); return true; } else if (!this.holdingSpawnEggOfClass(itemstack, this.getClass()) && this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking()) { if (this.buyingList == null) { this.initTrades(); } if (hand == EnumHand.MAIN_HAND) { player.addStat(StatList.TALKED_TO_VILLAGER); } if (!this.world.isRemote && !this.buyingList.isEmpty()) { this.setCustomer(player); player.displayVillagerTradeGui(this); } else if (this.buyingList.isEmpty()) { return super.processInteract(player, hand); } return true; } else { return super.processInteract(player, hand); } }
Example 6
Source Project: OpenModsLib File: OpenBlock.java License: MIT License | 5 votes |
@Override public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, @Nonnull ItemStack stack) { player.addStat(StatList.getBlockStats(this)); player.addExhaustion(0.025F); if (canSilkHarvest(world, pos, state, player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0) { handleSilkTouchDrops(world, player, pos, state, te); } else { handleNormalDrops(world, player, pos, state, te, stack); } }
Example 7
Source Project: TofuCraftReload File: ItemBugle.java License: MIT License | 5 votes |
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); playerIn.getCooldownTracker().setCooldown(stack.getItem(), 100); playerIn.playSound(TofuSounds.TOFUBUGLE, 20.0F, 1.0F); playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack); }
Example 8
Source Project: Electro-Magic-Tools File: ItemBaseOmnitool.java License: GNU General Public License v3.0 | 5 votes |
@Override public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { if (player.worldObj.isRemote) { return false; } Block block = player.worldObj.getBlock(x, y, z); if (block instanceof IShearable) { IShearable target = (IShearable) block; if (target.isShearable(stack, player.worldObj, x, y, z)) { ArrayList<ItemStack> drops = target.onSheared(stack, player.worldObj, x, y, z, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack)); Random rand = new Random(); for (ItemStack drop : drops) { float f = 0.7F; double d = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; double d1 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; double d2 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; EntityItem entityitem = new EntityItem(player.worldObj, (double) x + d, (double) y + d1, (double) z + d2, drop); entityitem.delayBeforeCanPickup = 10; player.worldObj.spawnEntityInWorld(entityitem); } stack.damageItem(1, player); player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1); } } return false; }
Example 9
Source Project: TofuCraftReload File: BlockUnderVine.java License: MIT License | 5 votes |
@Override public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) { if (!worldIn.isRemote && stack.getItem() == Items.SHEARS) { player.addStat(StatList.getBlockStats(this)); spawnAsEntity(worldIn, pos, new ItemStack(this, 1)); } else { super.harvestBlock(worldIn, player, pos, state, te, stack); } }
Example 10
Source Project: Electro-Magic-Tools File: ItemBaseChainsaw.java License: GNU General Public License v3.0 | 5 votes |
@Override public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) { if (player.worldObj.isRemote) { return false; } Block block = player.worldObj.getBlock(x, y, z); if (block instanceof IShearable) { IShearable target = (IShearable) block; if (target.isShearable(stack, player.worldObj, x, y, z)) { ArrayList<ItemStack> drops = target.onSheared(stack, player.worldObj, x, y, z, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack)); Random rand = new Random(); for (ItemStack drop : drops) { float f = 0.7F; double d = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; double d1 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; double d2 = (double) (rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D; EntityItem entityitem = new EntityItem(player.worldObj, (double) x + d, (double) y + d1, (double) z + d2, drop); entityitem.delayBeforeCanPickup = 10; player.worldObj.spawnEntityInWorld(entityitem); } stack.damageItem(1, player); player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1); } } return false; }
Example 11
Source Project: GT-Classic File: GTItemFluidTube.java License: GNU Lesser General Public License v3.0 | 5 votes |
public ActionResult<ItemStack> tryPlaceFluid(@Nonnull World world, @Nonnull EntityPlayer player, @Nonnull EnumHand hand, ItemStack itemstack, FluidStack fluidStack) { RayTraceResult mop = this.rayTrace(world, player, false); ActionResult<ItemStack> ret = ForgeEventFactory.onBucketUse(player, world, itemstack, mop); if (ret != null) return ret; if (mop == null || mop.typeOfHit != RayTraceResult.Type.BLOCK) { return ActionResult.newResult(EnumActionResult.PASS, itemstack); } BlockPos clickPos = mop.getBlockPos(); if (world.isBlockModifiable(player, clickPos)) { BlockPos targetPos = clickPos.offset(mop.sideHit); if (player.canPlayerEdit(targetPos, mop.sideHit, itemstack)) { FluidActionResult result = FluidUtil.tryPlaceFluid(player, world, targetPos, itemstack, fluidStack); if (result.isSuccess() && !player.capabilities.isCreativeMode) { player.addStat(StatList.getObjectUseStats(this)); itemstack.shrink(1); ItemStack emptyStack = new ItemStack(GTItems.testTube); if (itemstack.isEmpty()) { return ActionResult.newResult(EnumActionResult.SUCCESS, emptyStack); } else { ItemHandlerHelper.giveItemToPlayer(player, emptyStack); return ActionResult.newResult(EnumActionResult.SUCCESS, itemstack); } } } } return ActionResult.newResult(EnumActionResult.FAIL, itemstack); }
Example 12
Source Project: Production-Line File: ItemPLFood.java License: MIT License | 5 votes |
@Nullable @Override public ItemStack onItemUseFinish(@Nonnull ItemStack stack, World worldIn, EntityLivingBase entityLiving) { --stack.stackSize; if (entityLiving instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) entityLiving; entityplayer.getFoodStats().addStats(healAmount, saturationModifier); worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F); this.onEaten(stack, worldIn, entityplayer); entityplayer.addStat(StatList.getObjectUseStats(this)); } return stack; }
Example 13
Source Project: Chisel-2 File: BlockCarvableIce.java License: GNU General Public License v2.0 | 5 votes |
@Override public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1); par2EntityPlayer.addExhaustion(0.025F); /* * if(this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack = * this.createStackedBlock(par6); * * if(itemstack != null) { this.dropBlockAsItem(par1World, par3, par4, par5, itemstack); } } */ }
Example 14
Source Project: WearableBackpacks File: BlockBackpack.java License: MIT License | 5 votes |
@Override 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); harvesters.set(player); dropBackpack(worldIn, pos, te); harvesters.set(null); }
Example 15
Source Project: BaseMetals File: ItemMetalIngot.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Override public void onCreated(final ItemStack item, final World world, final EntityPlayer crafter) { super.onCreated(item, world, crafter); crafter.addStat(Achievements.this_is_new, 1); if(metal == Materials.aquarium) crafter.addStat(Achievements.aquarium_maker, 1); if(metal == Materials.brass) crafter.addStat(Achievements.brass_maker, 1); if(metal == Materials.bronze) crafter.addStat(Achievements.bronze_maker, 1); if(metal == Materials.electrum) crafter.addStat(Achievements.electrum_maker, 1); if(metal == Materials.steel) crafter.addStat(Achievements.steel_maker, 1); if(metal == Materials.invar) crafter.addStat(Achievements.invar_maker, 1); if(metal == Materials.mithril) crafter.addStat(Achievements.mithril_maker, 1); if(metal == Materials.cupronickel) crafter.addStat(Achievements.cupronickel_maker, 1); }
Example 16
Source Project: BaseMetals File: ItemMetalCrackHammer.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Override public void onCreated(final ItemStack item, final World world, final EntityPlayer crafter) { super.onCreated(item, world, crafter); MetalToolEffects.extraEffectsOnCrafting(metal,item, world, crafter); // achievement crafter.addStat(Achievements.geologist, 1); }
Example 17
Source Project: BaseMetals File: ItemMetalBlend.java License: GNU Lesser General Public License v2.1 | 5 votes |
@Override public void onCreated(final ItemStack item, final World world, final EntityPlayer crafter) { super.onCreated(item, world, crafter); // achievement // achievement if(metal == Materials.aquarium || metal == Materials.brass || metal == Materials.bronze || metal == Materials.electrum || metal == Materials.invar || metal == Materials.steel ){ crafter.addStat(Achievements.metallurgy, 1); } }
Example 18
Source Project: TFC2 File: GuiInventoryTFC.java License: GNU General Public License v3.0 | 5 votes |
public GuiInventoryTFC(EntityPlayer player) { super(player.inventoryContainer); this.allowUserInput = true; player.addStat(AchievementList.OPEN_INVENTORY, 1); xSize = 176; ySize = 102 + PlayerInventory.invYSize; this.player = player; }
Example 19
Source Project: TofuCraftReload File: ItemZundaBow.java License: MIT License | 4 votes |
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { if (entityLiving instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)entityLiving; boolean flag = entityplayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0; ItemStack itemstack = this.findAmmo(entityplayer); int i = this.getMaxItemUseDuration(stack) - timeLeft; i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(stack, worldIn, entityplayer, i, !itemstack.isEmpty() || flag); if (i < 0) return; if (!itemstack.isEmpty() || flag) { if (itemstack.isEmpty()) { itemstack = new ItemStack(Items.ARROW); } float f = getArrowVelocity(i); if ((double)f >= 0.1D) { boolean flag1 = entityplayer.capabilities.isCreativeMode || (itemstack.getItem() instanceof ItemArrow && ((ItemArrow) itemstack.getItem()).isInfinite(itemstack, stack, entityplayer)); if (!worldIn.isRemote) { ItemArrow itemarrow = (ItemArrow)(itemstack.getItem() instanceof ItemArrow ? itemstack.getItem() : Items.ARROW); EntityArrow entityarrow = itemarrow.createArrow(worldIn, itemstack, entityplayer); entityarrow.shoot(entityplayer, entityplayer.rotationPitch, entityplayer.rotationYaw, 0.0F, f * 3.05F, 1.0F); if (f == 1.0F) { entityarrow.setIsCritical(true); } int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack); if(entityarrow instanceof EntityZundaArrow){ entityarrow.setDamage(entityarrow.getDamage() + 2.0D); } if (j > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); if (k > 0) { entityarrow.setKnockbackStrength(k); } if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) { entityarrow.setFire(100); } stack.damageItem(1, entityplayer); if (flag1 || entityplayer.capabilities.isCreativeMode && (itemstack.getItem() == Items.SPECTRAL_ARROW || itemstack.getItem() == Items.TIPPED_ARROW)) { entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY; } worldIn.spawnEntity(entityarrow); } worldIn.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (!flag1 && !entityplayer.capabilities.isCreativeMode) { itemstack.shrink(1); if (itemstack.isEmpty()) { entityplayer.inventory.deleteStack(itemstack); } } entityplayer.addStat(StatList.getObjectUseStats(this)); } } } }
Example 20
Source Project: TFC2 File: BlockPitKiln.java License: GNU General Public License v3.0 | 4 votes |
@Override 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); }