Arctic_Wolfy

Move Player #1

Sep 2nd, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. @Override
  2. public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entity) {
  3.     BlockPos pos = getLocation(stack);
  4.     if (pos != null) {
  5.         BlockPos bedLoc = EntityPlayer.getBedSpawnLocation(world,
  6.                 pos, false);
  7.         if (bedLoc != null) {
  8.             if (entity instanceof EntityPlayerMP) {
  9.                 EntityPlayerMP player = (EntityPlayerMP) entity;
  10.                 player.dismountRidingEntity();
  11.                 player.attemptTeleport(
  12.                         bedLoc.getX() + .5,
  13.                         bedLoc.getY() + .1,
  14.                         bedLoc.getZ() + .5
  15.                 );
  16.                 /*player.connection.setPlayerLocation(
  17.                         bedLoc.getX() + .5,
  18.                         bedLoc.getY() + .1,
  19.                         bedLoc.getZ() + .5,
  20.                         entity.rotationYaw,
  21.                         entity.rotationPitch
  22.                 );*/
  23.             } else if (!(entity instanceof EntityPlayer)) {
  24.                 entity.setLocationAndAngles(
  25.                         bedLoc.getX() + .5,
  26.                         bedLoc.getY() + .1,
  27.                         bedLoc.getZ() + .5,
  28.                         entity.rotationYaw,
  29.                         entity.rotationPitch
  30.                 );
  31.             }
  32.         }
  33.     }
  34.     return stack;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment