public void dropPlayerItemWithRandomChoice(ItemStack itemstack, boolean flag) { if (itemstack == null) { return; } EntityItem entityitem = new EntityItem( worldObj, posX, (posY - 0.30000001192092896D) + (double) getEyeHeight(), posZ, itemstack); entityitem.delayBeforeCanPickup = 40; float f = 0.1F; if (flag) { float f2 = rand.nextFloat() * 0.5F; float f4 = rand.nextFloat() * 3.141593F * 2.0F; entityitem.motionX = -MathHelper.sin(f4) * f2; entityitem.motionZ = MathHelper.cos(f4) * f2; entityitem.motionY = 0.20000000298023224D; } else { float f1 = 0.3F; entityitem.motionX = -MathHelper.sin((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F) * f1; entityitem.motionZ = MathHelper.cos((rotationYaw / 180F) * 3.141593F) * MathHelper.cos((rotationPitch / 180F) * 3.141593F) * f1; entityitem.motionY = -MathHelper.sin((rotationPitch / 180F) * 3.141593F) * f1 + 0.1F; f1 = 0.02F; float f3 = rand.nextFloat() * 3.141593F * 2.0F; f1 *= rand.nextFloat(); entityitem.motionX += Math.cos(f3) * (double) f1; entityitem.motionY += (rand.nextFloat() - rand.nextFloat()) * 0.1F; entityitem.motionZ += Math.sin(f3) * (double) f1; } joinEntityItemWithWorld(entityitem); addStat(StatList.dropStat, 1); }
public void onDeath(DamageSource damagesource) { super.onDeath(damagesource); setSize(0.2F, 0.2F); setPosition(posX, posY, posZ); motionY = 0.10000000149011612D; if (username.equals("Notch")) { dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true); } inventory.dropAllItems(); if (damagesource != null) { motionX = -MathHelper.cos(((attackedAtYaw + rotationYaw) * 3.141593F) / 180F) * 0.1F; motionZ = -MathHelper.sin(((attackedAtYaw + rotationYaw) * 3.141593F) / 180F) * 0.1F; } else { motionX = motionZ = 0.0D; } yOffset = 0.1F; addStat(StatList.deathsStat, 1); }
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); } }