Advertisement
GamingLVScripts

dropItem

Apr 1st, 2024
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.40 KB | None | 0 0
  1. public EntityItem dropItem(ItemStack droppedItem, boolean dropAround, boolean traceItem)
  2.     {
  3.         if (droppedItem == null)
  4.         {
  5.             return null;
  6.         }
  7.         else if (droppedItem.stackSize == 0)
  8.         {
  9.             return null;
  10.         }
  11.         else
  12.         {
  13.             double d0 = this.posY - 0.30000001192092896D + (double)this.getEyeHeight();
  14.             EntityItem entityitem = new EntityItem(this.worldObj, this.posX, d0, this.posZ, droppedItem);
  15.             entityitem.setPickupDelay(40);
  16.  
  17.             if (traceItem)
  18.             {
  19.                 entityitem.setThrower(this.getCommandSenderName());
  20.             }
  21.  
  22.             if (dropAround)
  23.             {
  24.                 float f = this.rand.nextFloat() * 0.5F;
  25.                 float f1 = this.rand.nextFloat() * (float)Math.PI * 2.0F;
  26.                 entityitem.motionX = (double)(-MathHelper.sin(f1) * f);
  27.                 entityitem.motionZ = (double)(MathHelper.cos(f1) * f);
  28.                 entityitem.motionY = 0.20000000298023224D;
  29.             }
  30.             else
  31.             {
  32.                 float f2 = 0.3F;
  33.                 float yaw = this.rotationYaw;
  34.                 float pitch = this.rotationYaw;
  35.                 if(this == Minecraft.getMinecraft().thePlayer) {
  36.                     yaw = PlayerHandler.yaw;
  37.                     pitch = PlayerHandler.pitch;
  38.                 }
  39.                 entityitem.motionX = (double) (-MathHelper.sin(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(pitch / 180.0F * (float) Math.PI) * f2);
  40.                 entityitem.motionZ = (double) (MathHelper.cos(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(pitch / 180.0F * (float) Math.PI) * f2);
  41.                 entityitem.motionY = (double) (-MathHelper.sin(pitch / 180.0F * (float) Math.PI) * f2 + 0.1F);
  42.                 float f3 = this.rand.nextFloat() * (float) Math.PI * 2.0F;
  43.                 f2 = 0.02F * this.rand.nextFloat();
  44.                 entityitem.motionX += Math.cos((double) f3) * (double) f2;
  45.                 entityitem.motionY += (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
  46.                 entityitem.motionZ += Math.sin((double) f3) * (double) f2;
  47.             }
  48.  
  49.             this.joinEntityItemWithWorld(entityitem);
  50.  
  51.             if (traceItem)
  52.             {
  53.                 this.triggerAchievement(StatList.dropStat);
  54.             }
  55.  
  56.             return entityitem;
  57.         }
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement