/** Calls the corresponding fct in di */ public void hitEntity(EntityLivingBase par1EntityLivingBase, EntityPlayer par2EntityPlayer) { boolean flag = this.field_151002_e.hitEntity(this, par1EntityLivingBase, par2EntityPlayer); if (flag) { par2EntityPlayer.addStat(StatList.objectUseStats[Item.getIdFromItem(this.field_151002_e)], 1); } }
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { MovingObjectPosition var4 = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, false); if (var4 != null && var4.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && worldIn.getBlockState(var4.func_178782_a()).getBlock() == Blocks.end_portal_frame) { return itemStackIn; } else { if (!worldIn.isRemote) { BlockPos var5 = worldIn.func_180499_a("Stronghold", new BlockPos(playerIn)); if (var5 != null) { EntityEnderEye var6 = new EntityEnderEye(worldIn, playerIn.posX, playerIn.posY, playerIn.posZ); var6.func_180465_a(var5); worldIn.spawnEntityInWorld(var6); worldIn.playSoundAtEntity( playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); worldIn.playAuxSFXAtEntity((EntityPlayer) null, 1002, new BlockPos(playerIn), 0); if (!playerIn.capabilities.isCreativeMode) { --itemStackIn.stackSize; } playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); } } return itemStackIn; } }
/** Damages the item in the ItemStack */ public void damageItem(int par1, EntityLivingBase par2EntityLivingBase) { if (!(par2EntityLivingBase instanceof EntityPlayer) || !((EntityPlayer) par2EntityLivingBase).capabilities.isCreativeMode) { if (this.isItemStackDamageable()) { if (this.attemptDamageItem(par1, par2EntityLivingBase.getRNG())) { par2EntityLivingBase.renderBrokenItemStack(this); --this.stackSize; if (par2EntityLivingBase instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) par2EntityLivingBase; entityplayer.addStat( StatList.objectBreakStats[Item.getIdFromItem(this.field_151002_e)], 1); if (this.stackSize == 0 && this.getItem() instanceof ItemBow) { entityplayer.destroyCurrentEquippedItem(); } } if (this.stackSize < 0) { this.stackSize = 0; } this.itemDamage = 0; } } } }
/** Write the stack fields to a NBT object. Return the new NBT object. */ public NBTTagCompound writeToNBT(NBTTagCompound par1NBTTagCompound) { par1NBTTagCompound.setShort("id", (short) Item.getIdFromItem(this.field_151002_e)); par1NBTTagCompound.setByte("Count", (byte) this.stackSize); par1NBTTagCompound.setShort("Damage", (short) this.itemDamage); if (this.stackTagCompound != null) { par1NBTTagCompound.setTag("tag", this.stackTagCompound); } return par1NBTTagCompound; }
public void onPlayerStoppedUsing( ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) { boolean var5 = playerIn.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0; if (var5 || playerIn.inventory.hasItem(Items.arrow)) { int var6 = this.getMaxItemUseDuration(stack) - timeLeft; float var7 = (float) var6 / 20.0F; var7 = (var7 * var7 + var7 * 2.0F) / 3.0F; if ((double) var7 < 0.1D) { return; } if (var7 > 1.0F) { var7 = 1.0F; } EntityArrow var8 = new EntityArrow(worldIn, playerIn, var7 * 2.0F); if (var7 == 1.0F) { var8.setIsCritical(true); } int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack); if (var9 > 0) { var8.setDamage(var8.getDamage() + (double) var9 * 0.5D + 0.5D); } int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack); if (var10 > 0) { var8.setKnockbackStrength(var10); } if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0) { var8.setFire(100); } stack.damageItem(1, playerIn); worldIn.playSoundAtEntity( playerIn, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F); if (var5) { var8.canBePickedUp = 2; } else { playerIn.inventory.consumeInventoryItem(Items.arrow); } playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); if (!worldIn.isRemote) { worldIn.spawnEntityInWorld(var8); } } }
public void func_150999_a( World p_150999_1_, Block p_150999_2_, int p_150999_3_, int p_150999_4_, int p_150999_5_, EntityPlayer p_150999_6_) { boolean flag = this.field_151002_e.onBlockDestroyed( this, p_150999_1_, p_150999_2_, p_150999_3_, p_150999_4_, p_150999_5_, p_150999_6_); if (flag) { p_150999_6_.addStat(StatList.objectUseStats[Item.getIdFromItem(this.field_151002_e)], 1); } }
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { if (playerIn.capabilities.isCreativeMode) { return itemStackIn; } else { --itemStackIn.stackSize; worldIn.playSoundAtEntity( playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { worldIn.spawnEntityInWorld(new EntityEnderPearl(worldIn, playerIn)); } playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); return itemStackIn; } }
public boolean tryPlaceItemIntoWorld( EntityPlayer par1EntityPlayer, World par2World, int par3, int par4, int par5, int par6, float par7, float par8, float par9) { boolean flag = this.getItem() .onItemUse(this, par1EntityPlayer, par2World, par3, par4, par5, par6, par7, par8, par9); if (flag) { par1EntityPlayer.addStat(StatList.objectUseStats[Item.getIdFromItem(this.field_151002_e)], 1); } return flag; }
/** Return a list of strings containing information about the item */ @SideOnly(Side.CLIENT) public List getTooltip(EntityPlayer par1EntityPlayer, boolean par2) { ArrayList arraylist = new ArrayList(); String s = this.getDisplayName(); if (this.hasDisplayName()) { s = EnumChatFormatting.ITALIC + s + EnumChatFormatting.RESET; } int i; if (par2) { String s1 = ""; if (s.length() > 0) { s = s + " ("; s1 = ")"; } i = Item.getIdFromItem(this.field_151002_e); if (this.getHasSubtypes()) { s = s + String.format( "#%04d/%d%s", new Object[] {Integer.valueOf(i), Integer.valueOf(this.itemDamage), s1}); } else { s = s + String.format("#%04d%s", new Object[] {Integer.valueOf(i), s1}); } } else if (!this.hasDisplayName() && this.field_151002_e == Items.filled_map) { s = s + " #" + this.itemDamage; } arraylist.add(s); this.field_151002_e.addInformation(this, par1EntityPlayer, arraylist, par2); if (this.hasTagCompound()) { NBTTagList nbttaglist = this.getEnchantmentTagList(); if (nbttaglist != null) { for (i = 0; i < nbttaglist.tagCount(); ++i) { short short1 = nbttaglist.getCompoundTagAt(i).getShort("id"); short short2 = nbttaglist.getCompoundTagAt(i).getShort("lvl"); if (Enchantment.enchantmentsList[short1] != null) { arraylist.add(Enchantment.enchantmentsList[short1].getTranslatedName(short2)); } } } if (this.stackTagCompound.hasKey("display", 10)) { NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display"); if (nbttagcompound.hasKey("color", 3)) { if (par2) { arraylist.add( "Color: #" + Integer.toHexString(nbttagcompound.getInteger("color")).toUpperCase()); } else { arraylist.add(EnumChatFormatting.ITALIC + StatCollector.translateToLocal("item.dyed")); } } if (nbttagcompound.func_150299_b("Lore") == 9) { NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); if (nbttaglist1.tagCount() > 0) { for (int j = 0; j < nbttaglist1.tagCount(); ++j) { arraylist.add( EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + nbttaglist1.getStringTagAt(j)); } } } } } Multimap multimap = this.getAttributeModifiers(); if (!multimap.isEmpty()) { arraylist.add(""); Iterator iterator = multimap.entries().iterator(); while (iterator.hasNext()) { Entry entry = (Entry) iterator.next(); AttributeModifier attributemodifier = (AttributeModifier) entry.getValue(); double d0 = attributemodifier.getAmount(); double d1; if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) { d1 = attributemodifier.getAmount(); } else { d1 = attributemodifier.getAmount() * 100.0D; } if (d0 > 0.0D) { arraylist.add( EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted( "attribute.modifier.plus." + attributemodifier.getOperation(), new Object[] { field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + (String) entry.getKey()) })); } else if (d0 < 0.0D) { d1 *= -1.0D; arraylist.add( EnumChatFormatting.RED + StatCollector.translateToLocalFormatted( "attribute.modifier.take." + attributemodifier.getOperation(), new Object[] { field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + (String) entry.getKey()) })); } } } if (this.hasTagCompound() && this.getTagCompound().getBoolean("Unbreakable")) { arraylist.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal("item.unbreakable")); } if (par2 && this.isItemDamaged()) { arraylist.add( "Durability: " + (this.getMaxDamage() - this.getItemDamageForDisplay()) + " / " + this.getMaxDamage()); } ForgeEventFactory.onItemTooltip(this, par1EntityPlayer, arraylist, par2); return arraylist; }
public void onCrafting(World par1World, EntityPlayer par2EntityPlayer, int par3) { par2EntityPlayer.addStat( StatList.objectCraftStats[Item.getIdFromItem(this.field_151002_e)], par3); this.field_151002_e.onCreated(this, par1World, par2EntityPlayer); }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, * world, entityPlayer */ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { playerIn.displayGUIBook(itemStackIn); playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); return itemStackIn; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, * world, entityPlayer */ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, Player playerIn) { boolean flag = this.isFull == Blocks.air; MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, flag); if (movingobjectposition == null) { return itemStackIn; } else { if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { BlockPos blockpos = movingobjectposition.getBlockPos(); if (!worldIn.isBlockModifiable(playerIn, blockpos)) { return itemStackIn; } if (flag) { if (!playerIn.canPlayerEdit( blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn)) { return itemStackIn; } IBlockState iblockstate = worldIn.getBlockState(blockpos); Material material = iblockstate.getBlock().getMaterial(); if (material == Material.water && ((Integer) iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0) { worldIn.setBlockToAir(blockpos); playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); return this.fillBucket(itemStackIn, playerIn, Items.water_bucket); } if (material == Material.lava && ((Integer) iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0) { worldIn.setBlockToAir(blockpos); playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); return this.fillBucket(itemStackIn, playerIn, Items.lava_bucket); } } else { if (this.isFull == Blocks.air) { return new ItemStack(Items.bucket); } BlockPos blockpos1 = blockpos.offset(movingobjectposition.sideHit); if (!playerIn.canPlayerEdit(blockpos1, movingobjectposition.sideHit, itemStackIn)) { return itemStackIn; } if (this.tryPlaceContainedLiquid(worldIn, blockpos1) && !playerIn.capabilities.isCreativeMode) { playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); return new ItemStack(Items.bucket); } } } return itemStackIn; } }