/** * called when the player releases the use item button. Args: itemstack, world, entityplayer, * itemInUseCount */ public void onPlayerStoppedUsing( ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0; if (flag || par3EntityPlayer.inventory.hasItem(Item.arrow.shiftedIndex)) { int i = getMaxItemUseDuration(par1ItemStack) - par4; float f = (float) i / 20F; f = (f * f + f * 2.0F) / 3F; if ((double) f < 0.10000000000000001D) { return; } if (f > 1.0F) { f = 1.0F; } EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F); if (f == 1.0F) { entityarrow.func_56125_a(true); } int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack); if (j > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double) j * 0.5D + 0.5D); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack); if (k > 0) { entityarrow.func_46007_b(k); } if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0) { entityarrow.setFire(100); } par1ItemStack.damageItem(1, par3EntityPlayer); par2World.playSoundAtEntity( par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (flag) { entityarrow.field_58012_a = 2; } else { par3EntityPlayer.inventory.consumeInventoryItem(Item.arrow.shiftedIndex); } if (!par2World.isRemote) { par2World.spawnEntityInWorld(entityarrow); } } }
/** Attack the specified entity using a ranged attack. */ public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) { EntityArrow var3 = new EntityArrow( this.worldObj, this, par1EntityLivingBase, 1.6F, (float) (14 - this.worldObj.difficultySetting * 4)); int var4 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem()); int var5 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem()); var3.setDamage( (double) (par2 * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.difficultySetting * 0.11F)); if (var4 > 0) { var3.setDamage(var3.getDamage() + (double) var4 * 0.5D + 0.5D); } if (var5 > 0) { var3.setKnockbackStrength(var5); } if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.getSkeletonType() == 1) { var3.setFire(100); } this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(var3); }
public float getCurrentPlayerStrVsBlock(Block par1Block, int meta) { ItemStack stack = inventory.getCurrentItem(); float var2 = (stack == null ? 1.0F : stack.getItem().getStrVsBlock(stack, par1Block, meta)); float var3 = var2; int var4 = EnchantmentHelper.getEfficiencyModifier(this.inventory); if (var4 > 0 && this.inventory.canHarvestBlock(par1Block)) { var3 = var2 + (float) (var4 * var4 + 1); } if (this.isPotionActive(Potion.digSpeed)) { var3 *= 1.0F + (float) (this.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F; } if (this.isPotionActive(Potion.digSlowdown)) { var3 *= 1.0F - (float) (this.getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F; } if (this.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(this.inventory)) { var3 /= 5.0F; } if (!this.onGround) { var3 /= 5.0F; } return var3; }
protected int decreaseAirSupply(int i) { int j = EnchantmentHelper.getRespiration(inventory); if (j > 0 && rand.nextInt(j + 1) > 0) { return i; } else { return super.decreaseAirSupply(i); } }
public float getCurrentPlayerStrVsBlock(Block block) { float f = inventory.getStrVsBlock(block); float f1 = f; int i = EnchantmentHelper.getEfficiencyModifier(inventory); if (i > 0 && inventory.canHarvestBlock(block)) { f1 += i * i + 1; } if (isPotionActive(Potion.digSpeed)) { f1 *= 1.0F + (float) (getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F; } if (isPotionActive(Potion.digSlowdown)) { f1 *= 1.0F - (float) (getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F; } if (isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(inventory)) { f1 /= 5F; } if (!onGround) { f1 /= 5F; } return f1; }
/** Attack the specified entity using a ranged attack. */ public void attackEntityWithRangedAttack(EntityLiving par1EntityLiving) { EntityArrow var2 = new EntityArrow(this.worldObj, this, par1EntityLiving, 1.6F, 12.0F); int var3 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem()); int var4 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem()); if (var3 > 0) { var2.setDamage(var2.getDamage() + (double) var3 * 0.5D + 0.5D); } if (var4 > 0) { var2.setKnockbackStrength(var4); } if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.getSkeletonType() == 1) { var2.setFire(100); } this.func_85030_a("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(var2); }
protected int applyPotionDamageCalculations(DamageSource damagesource, int i) { int j = super.applyPotionDamageCalculations(damagesource, i); if (j <= 0) { return 0; } int k = EnchantmentHelper.getEnchantmentModifierDamage(inventory, damagesource); if (k > 20) { k = 20; } if (k > 0 && k <= 20) { int l = 25 - k; int i1 = j * l + carryoverDamage; j = i1 / 25; carryoverDamage = i1 % 25; } return j; }
/** Reduces damage, depending on potions */ protected int applyPotionDamageCalculations(DamageSource par1DamageSource, int par2) { int var3 = super.applyPotionDamageCalculations(par1DamageSource, par2); if (var3 <= 0) { return 0; } else { int var4 = EnchantmentHelper.getEnchantmentModifierDamage(this.inventory, par1DamageSource); if (var4 > 20) { var4 = 20; } if (var4 > 0 && var4 <= 20) { int var5 = 25 - var4; int var6 = var3 * var5 + this.carryoverDamage; var3 = var6 / 25; this.carryoverDamage = var6 % 25; } return var3; } }
/** * based on the villagers profession add items, equipment, and recipies adds par1 random items to * the list of things that the villager wants to buy. (at most 1 of each wanted type is added) */ private void addDefaultEquipmentAndRecipies(int par1) { if (this.buyingList != null) { this.field_82191_bN = MathHelper.sqrt_float((float) this.buyingList.size()) * 0.2F; } else { this.field_82191_bN = 0.0F; } MerchantRecipeList var2; var2 = new MerchantRecipeList(); int var6; label50: switch (this.getProfession()) { case 0: addMerchantItem(var2, Item.wheat.itemID, this.rand, this.func_82188_j(0.9F)); addMerchantItem(var2, Block.cloth.blockID, this.rand, this.func_82188_j(0.5F)); addMerchantItem(var2, Item.chickenRaw.itemID, this.rand, this.func_82188_j(0.5F)); addMerchantItem(var2, Item.fishCooked.itemID, this.rand, this.func_82188_j(0.4F)); addBlacksmithItem(var2, Item.bread.itemID, this.rand, this.func_82188_j(0.9F)); addBlacksmithItem(var2, Item.melon.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.appleRed.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.cookie.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.shears.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.flintAndSteel.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.chickenCooked.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.arrow.itemID, this.rand, this.func_82188_j(0.5F)); if (this.rand.nextFloat() < this.func_82188_j(0.5F)) { var2.add( new MerchantRecipe( new ItemStack(Block.gravel, 10), new ItemStack(Item.emerald), new ItemStack(Item.flint.itemID, 4 + this.rand.nextInt(2), 0))); } break; case 1: addMerchantItem(var2, Item.paper.itemID, this.rand, this.func_82188_j(0.8F)); addMerchantItem(var2, Item.book.itemID, this.rand, this.func_82188_j(0.8F)); addMerchantItem(var2, Item.writtenBook.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Block.bookShelf.blockID, this.rand, this.func_82188_j(0.8F)); addBlacksmithItem(var2, Block.glass.blockID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.compass.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.pocketSundial.itemID, this.rand, this.func_82188_j(0.2F)); if (this.rand.nextFloat() < this.func_82188_j(0.07F)) { Enchantment var8 = Enchantment.field_92090_c[this.rand.nextInt(Enchantment.field_92090_c.length)]; int var10 = MathHelper.getRandomIntegerInRange(this.rand, var8.getMinLevel(), var8.getMaxLevel()); ItemStack var11 = Item.enchantedBook.func_92111_a(new EnchantmentData(var8, var10)); var6 = 2 + this.rand.nextInt(5 + var10 * 10) + 3 * var10; var2.add( new MerchantRecipe( new ItemStack(Item.book), new ItemStack(Item.emerald, var6), var11)); } break; case 2: addBlacksmithItem(var2, Item.eyeOfEnder.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.expBottle.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.redstone.itemID, this.rand, this.func_82188_j(0.4F)); addBlacksmithItem(var2, Block.glowStone.blockID, this.rand, this.func_82188_j(0.3F)); int[] var3 = new int[] { Item.swordIron.itemID, Item.swordDiamond.itemID, Item.plateIron.itemID, Item.plateDiamond.itemID, Item.axeIron.itemID, Item.axeDiamond.itemID, Item.pickaxeIron.itemID, Item.pickaxeDiamond.itemID }; int[] var4 = var3; int var5 = var3.length; var6 = 0; while (true) { if (var6 >= var5) { break label50; } int var7 = var4[var6]; if (this.rand.nextFloat() < this.func_82188_j(0.05F)) { var2.add( new MerchantRecipe( new ItemStack(var7, 1, 0), new ItemStack(Item.emerald, 2 + this.rand.nextInt(3), 0), EnchantmentHelper.addRandomEnchantment( this.rand, new ItemStack(var7, 1, 0), 5 + this.rand.nextInt(15)))); } ++var6; } case 3: addMerchantItem(var2, Item.coal.itemID, this.rand, this.func_82188_j(0.7F)); addMerchantItem(var2, Item.ingotIron.itemID, this.rand, this.func_82188_j(0.5F)); addMerchantItem(var2, Item.ingotGold.itemID, this.rand, this.func_82188_j(0.5F)); addMerchantItem(var2, Item.diamond.itemID, this.rand, this.func_82188_j(0.5F)); addBlacksmithItem(var2, Item.swordIron.itemID, this.rand, this.func_82188_j(0.5F)); addBlacksmithItem(var2, Item.swordDiamond.itemID, this.rand, this.func_82188_j(0.5F)); addBlacksmithItem(var2, Item.axeIron.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.axeDiamond.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.pickaxeIron.itemID, this.rand, this.func_82188_j(0.5F)); addBlacksmithItem(var2, Item.pickaxeDiamond.itemID, this.rand, this.func_82188_j(0.5F)); addBlacksmithItem(var2, Item.shovelIron.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.shovelDiamond.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.hoeIron.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.hoeDiamond.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.bootsIron.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.bootsDiamond.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.helmetIron.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.helmetDiamond.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.plateIron.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.plateDiamond.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.legsIron.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.legsDiamond.itemID, this.rand, this.func_82188_j(0.2F)); addBlacksmithItem(var2, Item.bootsChain.itemID, this.rand, this.func_82188_j(0.1F)); addBlacksmithItem(var2, Item.helmetChain.itemID, this.rand, this.func_82188_j(0.1F)); addBlacksmithItem(var2, Item.plateChain.itemID, this.rand, this.func_82188_j(0.1F)); addBlacksmithItem(var2, Item.legsChain.itemID, this.rand, this.func_82188_j(0.1F)); break; case 4: addMerchantItem(var2, Item.coal.itemID, this.rand, this.func_82188_j(0.7F)); addMerchantItem(var2, Item.porkRaw.itemID, this.rand, this.func_82188_j(0.5F)); addMerchantItem(var2, Item.beefRaw.itemID, this.rand, this.func_82188_j(0.5F)); addBlacksmithItem(var2, Item.saddle.itemID, this.rand, this.func_82188_j(0.1F)); addBlacksmithItem(var2, Item.plateLeather.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.bootsLeather.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.helmetLeather.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.legsLeather.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.porkCooked.itemID, this.rand, this.func_82188_j(0.3F)); addBlacksmithItem(var2, Item.beefCooked.itemID, this.rand, this.func_82188_j(0.3F)); } if (var2.isEmpty()) { addMerchantItem(var2, Item.ingotGold.itemID, this.rand, 1.0F); } Collections.shuffle(var2); if (this.buyingList == null) { this.buyingList = new MerchantRecipeList(); } for (int var9 = 0; var9 < par1 && var9 < var2.size(); ++var9) { this.buyingList.addToListWithCheck((MerchantRecipe) var2.get(var9)); } }
public void attackTargetEntityWithCurrentItem(Entity entity) { int i = inventory.getDamageVsEntity(entity); if (isPotionActive(Potion.damageBoost)) { i += 3 << getActivePotionEffect(Potion.damageBoost).getAmplifier(); } if (isPotionActive(Potion.weakness)) { i -= 2 << getActivePotionEffect(Potion.weakness).getAmplifier(); } int j = 0; int k = 0; if (entity instanceof EntityLiving) { k = EnchantmentHelper.getEnchantmentModifierLiving(inventory, (EntityLiving) entity); j += EnchantmentHelper.getKnockbackModifier(inventory, (EntityLiving) entity); } if (isSprinting()) { j++; } if (i > 0 || k > 0) { boolean flag = fallDistance > 0.0F && !onGround && !isOnLadder() && !isInWater() && !isPotionActive(Potion.blindness) && ridingEntity == null && (entity instanceof EntityLiving); if (flag) { i += rand.nextInt(i / 2 + 2); } i += k; boolean flag1 = entity.attackEntityFrom(DamageSource.causePlayerDamage(this), i); if (flag1) { if (j > 0) { entity.addVelocity( -MathHelper.sin((rotationYaw * 3.141593F) / 180F) * (float) j * 0.5F, 0.10000000000000001D, MathHelper.cos((rotationYaw * 3.141593F) / 180F) * (float) j * 0.5F); motionX *= 0.59999999999999998D; motionZ *= 0.59999999999999998D; setSprinting(false); } if (flag) { onCriticalHit(entity); } if (k > 0) { func_40183_c(entity); } if (i >= 18) { triggerAchievement(AchievementList.overkill); } } ItemStack itemstack = getCurrentEquippedItem(); if (itemstack != null && (entity instanceof EntityLiving)) { itemstack.hitEntity((EntityLiving) entity, this); if (itemstack.stackSize <= 0) { itemstack.onItemDestroyedByUse(this); destroyCurrentEquippedItem(); } } if (entity instanceof EntityLiving) { if (entity.isEntityAlive()) { alertWolves((EntityLiving) entity, true); } addStat(StatList.damageDealtStat, i); int l = EnchantmentHelper.getFireAspectModifier(inventory, (EntityLiving) entity); if (l > 0) { entity.setFire(l * 4); } } addExhaustion(0.3F); } }
/** * Attacks for the player the targeted entity with the currently equipped item. The equipped item * has hitEntity called on it. Args: targetEntity */ public void attackTargetEntityWithCurrentItem(Entity par1Entity) { if (!ForgeHooks.onEntityInteract(this, par1Entity, true)) { return; } ItemStack stack = getCurrentEquippedItem(); if (stack != null && stack.getItem().onLeftClickEntity(stack, this, par1Entity)) { return; } if (par1Entity.canAttackWithItem()) { int var2 = this.inventory.getDamageVsEntity(par1Entity); if (this.isPotionActive(Potion.damageBoost)) { var2 += 3 << this.getActivePotionEffect(Potion.damageBoost).getAmplifier(); } if (this.isPotionActive(Potion.weakness)) { var2 -= 2 << this.getActivePotionEffect(Potion.weakness).getAmplifier(); } int var3 = 0; int var4 = 0; if (par1Entity instanceof EntityLiving) { var4 = EnchantmentHelper.getEnchantmentModifierLiving( this.inventory, (EntityLiving) par1Entity); var3 += EnchantmentHelper.getKnockbackModifier(this.inventory, (EntityLiving) par1Entity); } if (this.isSprinting()) { ++var3; } if (var2 > 0 || var4 > 0) { boolean var5 = this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInWater() && !this.isPotionActive(Potion.blindness) && this.ridingEntity == null && par1Entity instanceof EntityLiving; if (var5) { var2 += this.rand.nextInt(var2 / 2 + 2); } var2 += var4; boolean var6 = par1Entity.attackEntityFrom(DamageSource.causePlayerDamage(this), var2); if (var6) { if (var3 > 0) { par1Entity.addVelocity( (double) (-MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F) * (float) var3 * 0.5F), 0.1D, (double) (MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F) * (float) var3 * 0.5F)); this.motionX *= 0.6D; this.motionZ *= 0.6D; this.setSprinting(false); } if (var5) { this.onCriticalHit(par1Entity); } if (var4 > 0) { this.onEnchantmentCritical(par1Entity); } if (var2 >= 18) { this.triggerAchievement(AchievementList.overkill); } this.setLastAttackingEntity(par1Entity); } ItemStack var7 = this.getCurrentEquippedItem(); if (var7 != null && par1Entity instanceof EntityLiving) { var7.hitEntity((EntityLiving) par1Entity, this); if (var7.stackSize <= 0) { var7.onItemDestroyedByUse(this); this.destroyCurrentEquippedItem(); } } if (par1Entity instanceof EntityLiving) { if (par1Entity.isEntityAlive()) { this.alertWolves((EntityLiving) par1Entity, true); } this.addStat(StatList.damageDealtStat, var2); int var8 = EnchantmentHelper.getFireAspectModifier(this.inventory, (EntityLiving) par1Entity); if (var8 > 0) { par1Entity.setFire(var8 * 4); } } this.addExhaustion(0.3F); } } }
/** Decrements the entity's air supply when underwater */ protected int decreaseAirSupply(int par1) { int var2 = EnchantmentHelper.getRespiration(this.inventory); return var2 > 0 && this.rand.nextInt(var2 + 1) > 0 ? par1 : super.decreaseAirSupply(par1); }
/** * called when the Anvil Input Slot changes, calculates the new result and puts it in the output * slot */ public void updateRepairOutput() { ItemStack var1 = this.inputSlots.getStackInSlot(0); this.maximumCost = 0; int var2 = 0; byte var3 = 0; int var4 = 0; if (var1 == null) { this.outputSlot.setInventorySlotContents(0, (ItemStack) null); this.maximumCost = 0; } else { ItemStack var5 = var1.copy(); ItemStack var6 = this.inputSlots.getStackInSlot(1); Map var7 = EnchantmentHelper.getEnchantments(var5); boolean var8 = false; int var19 = var3 + var1.getRepairCost() + (var6 == null ? 0 : var6.getRepairCost()); this.stackSizeToBeUsedInRepair = 0; int var9; int var10; int var11; int var13; int var14; Iterator var21; Enchantment var22; if (var6 != null) { var8 = var6.itemID == Item.enchantedBook.itemID && Item.enchantedBook.func_92110_g(var6).tagCount() > 0; if (var5.isItemStackDamageable() && Item.itemsList[var5.itemID].getIsRepairable(var1, var6)) { var9 = Math.min(var5.getItemDamageForDisplay(), var5.getMaxDamage() / 4); if (var9 <= 0) { this.outputSlot.setInventorySlotContents(0, (ItemStack) null); this.maximumCost = 0; return; } for (var10 = 0; var9 > 0 && var10 < var6.stackSize; ++var10) { var11 = var5.getItemDamageForDisplay() - var9; var5.setItemDamage(var11); var2 += Math.max(1, var9 / 100) + var7.size(); var9 = Math.min(var5.getItemDamageForDisplay(), var5.getMaxDamage() / 4); } this.stackSizeToBeUsedInRepair = var10; } else { if (!var8 && (var5.itemID != var6.itemID || !var5.isItemStackDamageable())) { this.outputSlot.setInventorySlotContents(0, (ItemStack) null); this.maximumCost = 0; return; } if (var5.isItemStackDamageable() && !var8) { var9 = var1.getMaxDamage() - var1.getItemDamageForDisplay(); var10 = var6.getMaxDamage() - var6.getItemDamageForDisplay(); var11 = var10 + var5.getMaxDamage() * 12 / 100; int var12 = var9 + var11; var13 = var5.getMaxDamage() - var12; if (var13 < 0) { var13 = 0; } if (var13 < var5.getItemDamage()) { var5.setItemDamage(var13); var2 += Math.max(1, var11 / 100); } } Map var20 = EnchantmentHelper.getEnchantments(var6); var21 = var20.keySet().iterator(); while (var21.hasNext()) { var11 = ((Integer) var21.next()).intValue(); var22 = Enchantment.enchantmentsList[var11]; var13 = var7.containsKey(Integer.valueOf(var11)) ? ((Integer) var7.get(Integer.valueOf(var11))).intValue() : 0; var14 = ((Integer) var20.get(Integer.valueOf(var11))).intValue(); int var10000; if (var13 == var14) { ++var14; var10000 = var14; } else { var10000 = Math.max(var14, var13); } var14 = var10000; int var15 = var14 - var13; boolean var16 = var22.canApply(var1); if (this.thePlayer.capabilities.isCreativeMode || var1.itemID == ItemEnchantedBook.enchantedBook.itemID) { var16 = true; } Iterator var17 = var7.keySet().iterator(); while (var17.hasNext()) { int var18 = ((Integer) var17.next()).intValue(); if (var18 != var11 && !var22.canApplyTogether(Enchantment.enchantmentsList[var18])) { var16 = false; var2 += var15; } } if (var16) { if (var14 > var22.getMaxLevel()) { var14 = var22.getMaxLevel(); } var7.put(Integer.valueOf(var11), Integer.valueOf(var14)); int var23 = 0; switch (var22.getWeight()) { case 1: var23 = 8; break; case 2: var23 = 4; case 3: case 4: case 6: case 7: case 8: case 9: default: break; case 5: var23 = 2; break; case 10: var23 = 1; } if (var8) { var23 = Math.max(1, var23 / 2); } var2 += var23 * var15; } } } } if (this.repairedItemName != null && this.repairedItemName.length() > 0 && !this.repairedItemName.equalsIgnoreCase( this.thePlayer.getTranslator().translateNamedKey(var1.getItemName())) && !this.repairedItemName.equals(var1.getDisplayName())) { var4 = var1.isItemStackDamageable() ? 7 : var1.stackSize * 5; var2 += var4; if (var1.hasDisplayName()) { var19 += var4 / 2; } var5.setItemName(this.repairedItemName); } var9 = 0; for (var21 = var7.keySet().iterator(); var21.hasNext(); var19 += var9 + var13 * var14) { var11 = ((Integer) var21.next()).intValue(); var22 = Enchantment.enchantmentsList[var11]; var13 = ((Integer) var7.get(Integer.valueOf(var11))).intValue(); var14 = 0; ++var9; switch (var22.getWeight()) { case 1: var14 = 8; break; case 2: var14 = 4; case 3: case 4: case 6: case 7: case 8: case 9: default: break; case 5: var14 = 2; break; case 10: var14 = 1; } if (var8) { var14 = Math.max(1, var14 / 2); } } if (var8) { var19 = Math.max(1, var19 / 2); } this.maximumCost = var19 + var2; if (var2 <= 0) { var5 = null; } if (var4 == var2 && var4 > 0 && this.maximumCost >= 40) { this.theWorld .getWorldLogAgent() .logInfo( "Naming an item only, cost too high; giving discount to cap cost to 39 levels"); this.maximumCost = 39; } if (this.maximumCost >= 40 && !this.thePlayer.capabilities.isCreativeMode) { var5 = null; } if (var5 != null) { var10 = var5.getRepairCost(); if (var6 != null && var10 < var6.getRepairCost()) { var10 = var6.getRepairCost(); } if (var5.hasDisplayName()) { var10 -= 9; } if (var10 < 0) { var10 = 0; } var10 += 2; var5.setRepairCost(var10); EnchantmentHelper.setEnchantments(var7, var5); } this.outputSlot.setInventorySlotContents(0, var5); this.detectAndSendChanges(); } }