public void addToPlayer( final EntityPlayer player, final int howMany ) { player.addStat( this.stat, howMany ); }
@Override public boolean onBlockStartBreak(@Nonnull ItemStack itemstack, @Nonnull BlockPos pos, EntityPlayer player) { if (player.world.isRemote) return false; Block block = player.world.getBlockState(pos).getBlock(); if(block instanceof IShearable) { IShearable target = (IShearable)block; if(target.isShearable(itemstack, player.world, pos)) { List<ItemStack> drops = target.onSheared(itemstack, player.world, pos, EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, itemstack)); Random rand = new Random(); for(ItemStack stack : drops) { float f = 0.7F; double d = rand.nextFloat() * f + (1D - f) * 0.5; double d1 = rand.nextFloat() * f + (1D - f) * 0.5; double d2 = rand.nextFloat() * f + (1D - f) * 0.5; EntityItem entityitem = new EntityItem(player.world, pos.getX() + d, pos.getY() + d1, pos.getZ() + d2, stack); entityitem.setPickupDelay(10); player.world.spawnEntity(entityitem); } ToolCommons.damageItem(itemstack, 1, player, MANA_PER_DAMAGE); player.addStat(StatList.getBlockStats(block), 1); return true; } } return false; }
@Override public void onBlockHarvested(World world, BlockPos pos, IBlockState state, @Nonnull EntityPlayer player) { if(state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER) { if(world.getBlockState(pos.down()).getBlock() == this) { if (!player.capabilities.isCreativeMode) { // IBlockState iblockstate = worldIn.getBlockState(pos.down()); // BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType) iblockstate.getValue(VARIANT); //if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS) { // worldIn.destroyBlock(pos.down(), true); //} else if (!world.isRemote) { // if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.SHEARS) { // this.onHarvest(worldIn, pos, iblockstate, player); // world.setBlockToAir(pos.down()); // } else { // world.destroyBlock(pos.down(), true); // } //} else { world.setBlockToAir(pos.down()); //} } else { world.setBlockToAir(pos.down()); } } } else if(player.capabilities.isCreativeMode && world.getBlockState(pos.up()).getBlock() == this) world.setBlockState(pos.up(), Blocks.AIR.getDefaultState(), 2); player.addStat(StatList.getBlockStats(this)); //super.onBlockHarvested(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, p_149681_6_); }
@SubscribeEvent public void onDeath(PlayerChangedDimensionEvent event) { if (event.toDim == HFMining.MINING_ID) { event.player.addStat(HFAchievements.theMine); } } }
@SuppressWarnings("null") private void supressed(EntityPlayer entityplayer) { entityplayer.addStat(StatList.getObjectUseStats(this)); }
@SuppressWarnings("null") private void supressed(EntityPlayer player) { player.addStat(StatList.getBlockStats(this)); }
@Override public boolean onBlockActivated(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull EntityPlayer playerIn, @Nonnull EnumHand hand, @Nonnull EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { playerIn.displayGui(new InterfacePaintedCraftingTable(worldIn, pos)); playerIn.addStat(StatList.CRAFTING_TABLE_INTERACTION); return true; } }
private boolean onHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) { player.addStat(StatList.getBlockStats(this)); return true; }
player.addStat(StatList.getObjectUseStats(this));
@Override public void onDeath(@Nonnull DamageSource cause) { super.onDeath(cause); EntityPlayer player = EntityHelper.getPlayerFromSource(cause); if (player != null) { player.addStat(HFAchievements.killChick); } }
@Override public void onDeath(@Nonnull DamageSource cause) { super.onDeath(cause); EntityPlayer player = EntityHelper.getPlayerFromSource(cause); if (player != null) { player.addStat(HFAchievements.killChicken); } }
@Override public void onDeath(@Nonnull DamageSource cause) { super.onDeath(cause); EntityPlayer player = EntityHelper.getPlayerFromSource(cause); if (player != null) { player.addStat(HFAchievements.killSheep); } }
@Override public void onDeath(DamageSource cause) { super.onDeath(cause); EntityPlayer player = EntityHelper.getPlayerFromSource(cause); if (player != null) { player.addStat(HFAchievements.killCow); } }
private void finish(EntityPlayer player, ItemStack stack) { enchanter.setInventorySlotContents(0, ItemStack.EMPTY); player.addStat(StatList.ITEM_ENCHANTED); if(player instanceof EntityPlayerMP) CriteriaTriggers.ENCHANTED_ITEM.trigger((EntityPlayerMP) player, stack, 1); player.world.playSound(null, enchanter.getPos(), SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.BLOCKS, 1.0F, player.world.rand.nextFloat() * 0.1F + 0.9F); }
/** * Spawns the block's drops in the world. By the time this is called the Block has possibly been set to air via Block.removedByPlayer */ 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(Item.getItemFromBlock(this), 1)); } else { super.harvestBlock(worldIn, player, pos, state, te, stack); } }
@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); } }
public void giveToPlayer(EntityPlayer player) { List<ItemStack> theItems = getResult(); EntityBasket.findBasketAndShip(player, theItems); for (ItemStack theItem: theItems) { if (theItem.hasTagCompound()) { player.addStat(HFAchievements.cooking); } HFTrackers.getPlayerTrackerFromPlayer(player).getTracking().addAsObtained(theItem); SpawnItemHelper.addToPlayerInventory(player, theItem); } result.clear(); //Clear out the result }
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); if (!worldIn.isRemote) { this.resolveContents(stack, playerIn); } playerIn.openGui(VampirismMod.instance, ModGuiHandler.ID_VAMPIRE_BOOK, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ); playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, stack); }
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if (!playerIn.capabilities.isCreativeMode) { itemstack.shrink(1); } worldIn.playSound((EntityPlayer) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { EntityHippogryphEgg entityegg = new EntityHippogryphEgg(worldIn, playerIn, itemstack); entityegg.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); worldIn.spawnEntity(entityegg); } playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemstack); }
@Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemstack = playerIn.getHeldItem(handIn); if(!playerIn.capabilities.isCreativeMode) itemstack.shrink(1); worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if(!worldIn.isRemote) { EntityParrotEgg entityegg = new EntityParrotEgg(worldIn, playerIn, itemstack.getItemDamage()); entityegg.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); worldIn.spawnEntity(entityegg); } playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); }