public void teleport(Entity entity, Vec3d target) throws CommandException { if(entity == null) { throw new CommandException("entity must not be NULL!"); } if(target == null) { throw new CommandException("target must not be NULL!"); } // XXX DISABLED FUNCTIONALITY: This doesn't work as expected. if(Boolean.FALSE.booleanValue() && entity instanceof EntityPlayerMP) { // special case code EnumSet<EnumFlags> enumset = EnumSet.noneOf(SPacketPlayerPosLook.EnumFlags.class); float f = entity.rotationPitch; float f1 = entity.rotationYaw; entity.startRiding((Entity)null); ((EntityPlayerMP)entity).connection.setPlayerLocation(target.xCoord, target.yCoord, target.zCoord, f, f1, enumset); entity.velocityChanged = true; return; } entity.setPositionAndUpdate(target.xCoord, target.yCoord, target.zCoord); entity.velocityChanged = true; }
@SubscribeEvent public void onPacketReceived (PacketEvent.Incoming.Pre event) { if (event.getPacket() instanceof SPacketPlayerPosLook) { SPacketPlayerPosLook packet = (SPacketPlayerPosLook) event.getPacket(); startPosX = packet.getX(); startPosY = packet.getY(); startPosZ = packet.getZ(); startPitch = packet.getPitch(); startYaw = packet.getYaw(); } }
@SubscribeEvent public void onOutgoingPacketSent(PacketEvent.Incoming.Pre event) { if (event.getPacket() instanceof SPacketPlayerPosLook) { SPacketPlayerPosLook packet = (SPacketPlayerPosLook) event.getPacket(); try { ObfuscationReflectionHelper.setPrivateValue(SPacketPlayerPosLook.class, packet, MC.player.rotationYaw, "yaw", "field_148936_d", "d"); ObfuscationReflectionHelper.setPrivateValue(SPacketPlayerPosLook.class, packet, MC.player.rotationPitch, "pitch", "field_148937_e", "e"); } catch (Exception e) {} } }
@SubscribeEvent public void onPacketRecieved(PacketEvent.Incoming.Pre event) { if (event.getPacket() instanceof SPacketPlayerPosLook) { SPacketPlayerPosLook packet = (SPacketPlayerPosLook) event.getPacket(); if (MC.player != null) if (MC.player.rotationYaw != -180 && MC.player.rotationPitch != 0) { FastReflection.Fields.SPacketPlayer_yaw.set(packet, MC.player.rotationYaw); FastReflection.Fields.SPacketPlayer_pitch.set(packet, MC.player.rotationPitch); } } }
public void setPlayerLocation(double x, double y, double z, float yaw, float pitch, Set<SPacketPlayerPosLook.EnumFlags> relativeSet) { double d0 = relativeSet.contains(SPacketPlayerPosLook.EnumFlags.X) ? this.playerEntity.posX : 0.0D; double d1 = relativeSet.contains(SPacketPlayerPosLook.EnumFlags.Y) ? this.playerEntity.posY : 0.0D; double d2 = relativeSet.contains(SPacketPlayerPosLook.EnumFlags.Z) ? this.playerEntity.posZ : 0.0D; this.targetPos = new Vec3d(x + d0, y + d1, z + d2); float f = yaw; float f1 = pitch; if (relativeSet.contains(SPacketPlayerPosLook.EnumFlags.Y_ROT)) { f = yaw + this.playerEntity.rotationYaw; } if (relativeSet.contains(SPacketPlayerPosLook.EnumFlags.X_ROT)) { f1 = pitch + this.playerEntity.rotationPitch; } if (++this.teleportId == Integer.MAX_VALUE) { this.teleportId = 0; } this.lastPositionUpdate = this.networkTickCount; this.playerEntity.setPositionAndRotation(this.targetPos.xCoord, this.targetPos.yCoord, this.targetPos.zCoord, f, f1); this.playerEntity.connection.sendPacket(new SPacketPlayerPosLook(x, y, z, yaw, pitch, relativeSet, this.teleportId)); }
@Override public IMessage onMessage(final TeleportMessage message, final MessageContext ctx) { // Don't act here - if we cause chunk loading on this thread (netty) then chunks will get // lost from the server. IThreadListener mainThread = null; if (ctx.side == Side.CLIENT) mainThread = Minecraft.getMinecraft(); else mainThread = (WorldServer)ctx.getServerHandler().playerEntity.world; mainThread.addScheduledTask(new Runnable() { @Override public void run() { EnumSet<SPacketPlayerPosLook.EnumFlags> enumset = EnumSet.noneOf(SPacketPlayerPosLook.EnumFlags.class); if (!message.setX) enumset.add(SPacketPlayerPosLook.EnumFlags.X); if (!message.setY) enumset.add(SPacketPlayerPosLook.EnumFlags.Y); if (!message.setZ) enumset.add(SPacketPlayerPosLook.EnumFlags.Z); if (!message.setYaw) enumset.add(SPacketPlayerPosLook.EnumFlags.Y_ROT); if (!message.setPitch) enumset.add(SPacketPlayerPosLook.EnumFlags.X_ROT); EntityPlayerMP player = ctx.getServerHandler().playerEntity; player.dismountRidingEntity(); player.connection.setPlayerLocation(message.x, message.y, message.z, message.yaw, message.pitch, enumset); player.setRotationYawHead(message.yaw); } }); return null; }
public void setPlayerLocation(double x, double y, double z, float yaw, float pitch) { this.setPlayerLocation(x, y, z, yaw, pitch, Collections.<SPacketPlayerPosLook.EnumFlags>emptySet()); }
public void handlePlayerPosLook(SPacketPlayerPosLook packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); EntityPlayer entityplayer = this.gameController.player; double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); float f = packetIn.getYaw(); float f1 = packetIn.getPitch(); if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.X)) { d0 += entityplayer.posX; } else { entityplayer.motionX = 0.0D; } if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y)) { d1 += entityplayer.posY; } else { entityplayer.motionY = 0.0D; } if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Z)) { d2 += entityplayer.posZ; } else { entityplayer.motionZ = 0.0D; } if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.X_ROT)) { f1 += entityplayer.rotationPitch; } if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y_ROT)) { f += entityplayer.rotationYaw; } entityplayer.setPositionAndRotation(d0, d1, d2, f, f1); this.netManager.sendPacket(new CPacketConfirmTeleport(packetIn.getTeleportId())); this.netManager.sendPacket(new CPacketPlayer.PositionRotation(entityplayer.posX, entityplayer.getEntityBoundingBox().minY, entityplayer.posZ, entityplayer.rotationYaw, entityplayer.rotationPitch, false)); if (!this.doneLoadingTerrain) { this.gameController.player.prevPosX = this.gameController.player.posX; this.gameController.player.prevPosY = this.gameController.player.posY; this.gameController.player.prevPosZ = this.gameController.player.posZ; this.doneLoadingTerrain = true; this.gameController.displayGuiScreen((GuiScreen)null); } }
/** * Perform the actual teleport */ private static void doTeleport(Entity p_189862_0_, CommandBase.CoordinateArg p_189862_1_, CommandBase.CoordinateArg p_189862_2_, CommandBase.CoordinateArg p_189862_3_, CommandBase.CoordinateArg p_189862_4_, CommandBase.CoordinateArg p_189862_5_) { if (p_189862_0_ instanceof EntityPlayerMP) { Set<SPacketPlayerPosLook.EnumFlags> set = EnumSet.<SPacketPlayerPosLook.EnumFlags>noneOf(SPacketPlayerPosLook.EnumFlags.class); float f = (float)p_189862_4_.getAmount(); if (p_189862_4_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Y_ROT); } else { f = MathHelper.wrapDegrees(f); } float f1 = (float)p_189862_5_.getAmount(); if (p_189862_5_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.X_ROT); } else { f1 = MathHelper.wrapDegrees(f1); } p_189862_0_.dismountRidingEntity(); ((EntityPlayerMP)p_189862_0_).connection.setPlayerLocation(p_189862_1_.getResult(), p_189862_2_.getResult(), p_189862_3_.getResult(), f, f1, set); p_189862_0_.setRotationYawHead(f); } else { float f2 = (float)MathHelper.wrapDegrees(p_189862_4_.getResult()); float f3 = (float)MathHelper.wrapDegrees(p_189862_5_.getResult()); f3 = MathHelper.clamp(f3, -90.0F, 90.0F); p_189862_0_.setLocationAndAngles(p_189862_1_.getResult(), p_189862_2_.getResult(), p_189862_3_.getResult(), f2, f3); p_189862_0_.setRotationYawHead(f2); } if (!(p_189862_0_ instanceof EntityLivingBase) || !((EntityLivingBase)p_189862_0_).isElytraFlying()) { p_189862_0_.motionY = 0.0D; p_189862_0_.onGround = true; } }
/** * Teleports an entity to the specified coordinates */ private static void teleportEntityToCoordinates(Entity p_189863_0_, CommandBase.CoordinateArg p_189863_1_, CommandBase.CoordinateArg p_189863_2_, CommandBase.CoordinateArg p_189863_3_, CommandBase.CoordinateArg p_189863_4_, CommandBase.CoordinateArg p_189863_5_) { if (p_189863_0_ instanceof EntityPlayerMP) { Set<SPacketPlayerPosLook.EnumFlags> set = EnumSet.<SPacketPlayerPosLook.EnumFlags>noneOf(SPacketPlayerPosLook.EnumFlags.class); if (p_189863_1_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.X); } if (p_189863_2_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Y); } if (p_189863_3_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Z); } if (p_189863_5_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.X_ROT); } if (p_189863_4_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Y_ROT); } float f = (float)p_189863_4_.getAmount(); if (!p_189863_4_.isRelative()) { f = MathHelper.wrapDegrees(f); } float f1 = (float)p_189863_5_.getAmount(); if (!p_189863_5_.isRelative()) { f1 = MathHelper.wrapDegrees(f1); } p_189863_0_.dismountRidingEntity(); ((EntityPlayerMP)p_189863_0_).connection.setPlayerLocation(p_189863_1_.getAmount(), p_189863_2_.getAmount(), p_189863_3_.getAmount(), f, f1, set); p_189863_0_.setRotationYawHead(f); } else { float f2 = (float)MathHelper.wrapDegrees(p_189863_4_.getResult()); float f3 = (float)MathHelper.wrapDegrees(p_189863_5_.getResult()); f3 = MathHelper.clamp(f3, -90.0F, 90.0F); p_189863_0_.setLocationAndAngles(p_189863_1_.getResult(), p_189863_2_.getResult(), p_189863_3_.getResult(), f2, f3); p_189863_0_.setRotationYawHead(f2); } if (!(p_189863_0_ instanceof EntityLivingBase) || !((EntityLivingBase)p_189863_0_).isElytraFlying()) { p_189863_0_.motionY = 0.0D; p_189863_0_.onGround = true; } }
public void handlePlayerPosLook(SPacketPlayerPosLook packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); EntityPlayer entityplayer = this.gameController.thePlayer; double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); float f = packetIn.getYaw(); float f1 = packetIn.getPitch(); if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.X)) { d0 += entityplayer.posX; } else { entityplayer.motionX = 0.0D; } if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y)) { d1 += entityplayer.posY; } else { entityplayer.motionY = 0.0D; } if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Z)) { d2 += entityplayer.posZ; } else { entityplayer.motionZ = 0.0D; } if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.X_ROT)) { f1 += entityplayer.rotationPitch; } if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y_ROT)) { f += entityplayer.rotationYaw; } entityplayer.setPositionAndRotation(d0, d1, d2, f, f1); this.netManager.sendPacket(new CPacketConfirmTeleport(packetIn.getTeleportId())); this.netManager.sendPacket(new CPacketPlayer.PositionRotation(entityplayer.posX, entityplayer.getEntityBoundingBox().minY, entityplayer.posZ, entityplayer.rotationYaw, entityplayer.rotationPitch, false)); if (!this.doneLoadingTerrain) { this.gameController.thePlayer.prevPosX = this.gameController.thePlayer.posX; this.gameController.thePlayer.prevPosY = this.gameController.thePlayer.posY; this.gameController.thePlayer.prevPosZ = this.gameController.thePlayer.posZ; this.doneLoadingTerrain = true; this.gameController.displayGuiScreen((GuiScreen)null); } }
/** * Perform the actual teleport */ private static void doTeleport(Entity p_189862_0_, CommandBase.CoordinateArg p_189862_1_, CommandBase.CoordinateArg p_189862_2_, CommandBase.CoordinateArg p_189862_3_, CommandBase.CoordinateArg p_189862_4_, CommandBase.CoordinateArg p_189862_5_) { if (p_189862_0_ instanceof EntityPlayerMP) { Set<SPacketPlayerPosLook.EnumFlags> set = EnumSet.<SPacketPlayerPosLook.EnumFlags>noneOf(SPacketPlayerPosLook.EnumFlags.class); float f = (float)p_189862_4_.getAmount(); if (p_189862_4_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Y_ROT); } else { f = MathHelper.wrapDegrees(f); } float f1 = (float)p_189862_5_.getAmount(); if (p_189862_5_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.X_ROT); } else { f1 = MathHelper.wrapDegrees(f1); } p_189862_0_.dismountRidingEntity(); ((EntityPlayerMP)p_189862_0_).connection.setPlayerLocation(p_189862_1_.getResult(), p_189862_2_.getResult(), p_189862_3_.getResult(), f, f1, set); p_189862_0_.setRotationYawHead(f); } else { float f2 = (float)MathHelper.wrapDegrees(p_189862_4_.getResult()); float f3 = (float)MathHelper.wrapDegrees(p_189862_5_.getResult()); f3 = MathHelper.clamp_float(f3, -90.0F, 90.0F); p_189862_0_.setLocationAndAngles(p_189862_1_.getResult(), p_189862_2_.getResult(), p_189862_3_.getResult(), f2, f3); p_189862_0_.setRotationYawHead(f2); } if (!(p_189862_0_ instanceof EntityLivingBase) || !((EntityLivingBase)p_189862_0_).isElytraFlying()) { p_189862_0_.motionY = 0.0D; p_189862_0_.onGround = true; } }
/** * Teleports an entity to the specified coordinates */ private static void teleportEntityToCoordinates(Entity p_189863_0_, CommandBase.CoordinateArg p_189863_1_, CommandBase.CoordinateArg p_189863_2_, CommandBase.CoordinateArg p_189863_3_, CommandBase.CoordinateArg p_189863_4_, CommandBase.CoordinateArg p_189863_5_) { if (p_189863_0_ instanceof EntityPlayerMP) { Set<SPacketPlayerPosLook.EnumFlags> set = EnumSet.<SPacketPlayerPosLook.EnumFlags>noneOf(SPacketPlayerPosLook.EnumFlags.class); if (p_189863_1_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.X); } if (p_189863_2_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Y); } if (p_189863_3_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Z); } if (p_189863_5_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.X_ROT); } if (p_189863_4_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Y_ROT); } float f = (float)p_189863_4_.getAmount(); if (!p_189863_4_.isRelative()) { f = MathHelper.wrapDegrees(f); } float f1 = (float)p_189863_5_.getAmount(); if (!p_189863_5_.isRelative()) { f1 = MathHelper.wrapDegrees(f1); } p_189863_0_.dismountRidingEntity(); ((EntityPlayerMP)p_189863_0_).connection.setPlayerLocation(p_189863_1_.getAmount(), p_189863_2_.getAmount(), p_189863_3_.getAmount(), f, f1, set); p_189863_0_.setRotationYawHead(f); } else { float f2 = (float)MathHelper.wrapDegrees(p_189863_4_.getResult()); float f3 = (float)MathHelper.wrapDegrees(p_189863_5_.getResult()); f3 = MathHelper.clamp_float(f3, -90.0F, 90.0F); p_189863_0_.setLocationAndAngles(p_189863_1_.getResult(), p_189863_2_.getResult(), p_189863_3_.getResult(), f2, f3); p_189863_0_.setRotationYawHead(f2); } if (!(p_189863_0_ instanceof EntityLivingBase) || !((EntityLivingBase)p_189863_0_).isElytraFlying()) { p_189863_0_.motionY = 0.0D; p_189863_0_.onGround = true; } }
@Override public void setPlayerLocation(double x, double y, double z, float yaw, float pitch, Set<SPacketPlayerPosLook.EnumFlags> relativeSet) { }
private static void func_189862_a(Entity p_189862_0_, CommandBase.CoordinateArg p_189862_1_, CommandBase.CoordinateArg p_189862_2_, CommandBase.CoordinateArg p_189862_3_, CommandBase.CoordinateArg p_189862_4_, CommandBase.CoordinateArg p_189862_5_) { if (p_189862_0_ instanceof EntityPlayerMP) { Set<SPacketPlayerPosLook.EnumFlags> set = EnumSet.<SPacketPlayerPosLook.EnumFlags>noneOf(SPacketPlayerPosLook.EnumFlags.class); float f = (float)p_189862_4_.getAmount(); if (p_189862_4_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Y_ROT); } else { f = MathHelper.wrapDegrees(f); } float f1 = (float)p_189862_5_.getAmount(); if (p_189862_5_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.X_ROT); } else { f1 = MathHelper.wrapDegrees(f1); } p_189862_0_.dismountRidingEntity(); ((EntityPlayerMP)p_189862_0_).connection.setPlayerLocation(p_189862_1_.getResult(), p_189862_2_.getResult(), p_189862_3_.getResult(), f, f1, set); p_189862_0_.setRotationYawHead(f); } else { float f2 = (float)MathHelper.wrapDegrees(p_189862_4_.getResult()); float f3 = (float)MathHelper.wrapDegrees(p_189862_5_.getResult()); f3 = MathHelper.clamp_float(f3, -90.0F, 90.0F); p_189862_0_.setLocationAndAngles(p_189862_1_.getResult(), p_189862_2_.getResult(), p_189862_3_.getResult(), f2, f3); p_189862_0_.setRotationYawHead(f2); } if (!(p_189862_0_ instanceof EntityLivingBase) || !((EntityLivingBase)p_189862_0_).isElytraFlying()) { p_189862_0_.motionY = 0.0D; p_189862_0_.onGround = true; } }
private static void func_189863_a(Entity p_189863_0_, CommandBase.CoordinateArg p_189863_1_, CommandBase.CoordinateArg p_189863_2_, CommandBase.CoordinateArg p_189863_3_, CommandBase.CoordinateArg p_189863_4_, CommandBase.CoordinateArg p_189863_5_) { if (p_189863_0_ instanceof EntityPlayerMP) { Set<SPacketPlayerPosLook.EnumFlags> set = EnumSet.<SPacketPlayerPosLook.EnumFlags>noneOf(SPacketPlayerPosLook.EnumFlags.class); if (p_189863_1_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.X); } if (p_189863_2_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Y); } if (p_189863_3_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Z); } if (p_189863_5_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.X_ROT); } if (p_189863_4_.isRelative()) { set.add(SPacketPlayerPosLook.EnumFlags.Y_ROT); } float f = (float)p_189863_4_.getAmount(); if (!p_189863_4_.isRelative()) { f = MathHelper.wrapDegrees(f); } float f1 = (float)p_189863_5_.getAmount(); if (!p_189863_5_.isRelative()) { f1 = MathHelper.wrapDegrees(f1); } p_189863_0_.dismountRidingEntity(); ((EntityPlayerMP)p_189863_0_).connection.setPlayerLocation(p_189863_1_.getAmount(), p_189863_2_.getAmount(), p_189863_3_.getAmount(), f, f1, set); p_189863_0_.setRotationYawHead(f); } else { float f2 = (float)MathHelper.wrapDegrees(p_189863_4_.getResult()); float f3 = (float)MathHelper.wrapDegrees(p_189863_5_.getResult()); f3 = MathHelper.clamp_float(f3, -90.0F, 90.0F); p_189863_0_.setLocationAndAngles(p_189863_1_.getResult(), p_189863_2_.getResult(), p_189863_3_.getResult(), f2, f3); p_189863_0_.setRotationYawHead(f2); } if (!(p_189863_0_ instanceof EntityLivingBase) || !((EntityLivingBase)p_189863_0_).isElytraFlying()) { p_189863_0_.motionY = 0.0D; p_189863_0_.onGround = true; } }
void handlePlayerPosLook(SPacketPlayerPosLook packetIn);