Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *supports teleporting entities from location to location in the same dimension doesn't support actual cross dimensional teleport
- */
- public static void doTeleport(Entity e, double x, double y, double z,float yaw, float pitch)
- {
- int chunkOldX = (int)e.posX >> 4;
- int chunkOldZ = (int)e.posZ >> 4;
- int chunkX = (int)x >> 4;
- int chunkZ = (int)z >> 4;
- //remove from old chunk
- if(chunkOldX != chunkX || chunkOldZ != chunkZ)
- {
- Chunk chunkOld = e.world.getChunkFromChunkCoords(chunkOldX,chunkOldZ);
- chunkOld.removeEntity(e);
- }
- if (e instanceof EntityPlayerMP)
- {
- Set<SPacketPlayerPosLook.EnumFlags> set = EnumSet.<SPacketPlayerPosLook.EnumFlags>noneOf(SPacketPlayerPosLook.EnumFlags.class);
- e.dismountRidingEntity();
- e.setLocationAndAngles(x, y, z, e.rotationYaw, e.rotationPitch);
- ((EntityPlayerMP)e).connection.setPlayerLocation(x, y, z, yaw, pitch, set);
- }
- else
- {
- float f2 = (float)MathHelper.wrapDegrees(yaw);
- float f3 = (float)MathHelper.wrapDegrees(pitch);
- f3 = MathHelper.clamp(f3, -90.0F, 90.0F);
- e.setLocationAndAngles(x, y, z, f2, f3);
- }
- if (!(e instanceof EntityLivingBase) || !((EntityLivingBase)e).isElytraFlying())
- {
- e.motionY = 0.0D;
- e.onGround = true;
- }
- //vanilla hotfix add entity to the chunk if not already added
- Chunk chunk = e.world.getChunkFromChunkCoords(chunkX,chunkZ);
- if(!containsEntity(chunk.getEntityLists(),e))
- chunk.addEntity(e);
- }
Add Comment
Please, Sign In to add comment