CanadianGamer

Chorus Fruit teleportion!

Aug 17th, 2020
1,542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1.  public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
  2.       ItemStack itemstack = super.onItemUseFinish(stack, worldIn, entityLiving);
  3.       if (!worldIn.isRemote) {
  4.          double d0 = entityLiving.getPosX();
  5.          double d1 = entityLiving.getPosY();
  6.          double d2 = entityLiving.getPosZ();
  7.  
  8.          for(int i = 0; i < 16; ++i) {
  9.             double d3 = entityLiving.getPosX() + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
  10.             double d4 = MathHelper.clamp(entityLiving.getPosY() + (double)(entityLiving.getRNG().nextInt(16) - 8), 0.0D, (double)(worldIn.getActualHeight() - 1));
  11.             double d5 = entityLiving.getPosZ() + (entityLiving.getRNG().nextDouble() - 0.5D) * 16.0D;
  12.             if (entityLiving.isPassenger()) {
  13.                entityLiving.stopRiding();
  14.             }
  15.  
  16.             if (entityLiving.attemptTeleport(d3, d4, d5, true)) {
  17.                worldIn.playSound((PlayerEntity)null, d0, d1, d2, SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
  18.                entityLiving.playSound(SoundEvents.ITEM_CHORUS_FRUIT_TELEPORT, 1.0F, 1.0F);
  19.                break;
  20.             }
  21.          }
  22.  
  23.          if (entityLiving instanceof PlayerEntity) {
  24.             ((PlayerEntity)entityLiving).getCooldownTracker().setCooldown(this, 20);
  25.          }
  26.       }
  27.  
  28.       return itemstack;
  29.    }
Advertisement
Add Comment
Please, Sign In to add comment