Java 类net.minecraft.network.play.server.SPacketEntityVelocity 实例源码

项目:Backmemed    文件:NetHandlerPlayClient.java   
/**
 * Sets the velocity of the specified entity to the specified value
 */
public void handleEntityVelocity(SPacketEntityVelocity packetIn)
{
    if(Hacks.findMod(AntiVelocity.class).isEnabled())
    {
        return;
    }

    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());

    if (entity != null)
    {
        entity.setVelocity((double)packetIn.getMotionX() / 8000.0D, (double)packetIn.getMotionY() / 8000.0D, (double)packetIn.getMotionZ() / 8000.0D);
    }
}
项目:Wizardry    文件:PosUtils.java   
public static void boom(World world, Vec3d pos, @Nullable Entity excluded, double scale, boolean reverseDirection) {
    List<Entity> entityList = world.getEntitiesWithinAABBExcludingEntity(excluded, new AxisAlignedBB(new BlockPos(pos)).grow(32, 32, 32));
    for (Entity entity1 : entityList) {
        double x = entity1.getDistance(pos.x, pos.y, pos.z) / 32.0;
        double magY;

        if (reverseDirection) magY = x;
        else magY = -x + 1;

        Vec3d dir = entity1.getPositionVector().subtract(pos).normalize().scale(reverseDirection ? -1 : 1).scale(magY).scale(scale);

        entity1.motionX += (dir.x);
        entity1.motionY += (dir.y);
        entity1.motionZ += (dir.z);
        entity1.fallDistance = 0;
        entity1.velocityChanged = true;

        if (entity1 instanceof EntityPlayerMP)
            ((EntityPlayerMP) entity1).connection.sendPacket(new SPacketEntityVelocity(entity1));
    }
}
项目:Zombe-Modpack    文件:NetHandlerPlayClient.java   
/**
 * Sets the velocity of the specified entity to the specified value
 */
public void handleEntityVelocity(SPacketEntityVelocity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());

    if (entity != null)
    {
        entity.setVelocity((double)packetIn.getMotionX() / 8000.0D, (double)packetIn.getMotionY() / 8000.0D, (double)packetIn.getMotionZ() / 8000.0D);
    }
}
项目:CustomWorldGen    文件:NetHandlerPlayClient.java   
/**
 * Sets the velocity of the specified entity to the specified value
 */
public void handleEntityVelocity(SPacketEntityVelocity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());

    if (entity != null)
    {
        entity.setVelocity((double)packetIn.getMotionX() / 8000.0D, (double)packetIn.getMotionY() / 8000.0D, (double)packetIn.getMotionZ() / 8000.0D);
    }
}
项目:Whoosh    文件:TeleportUtil.java   
private static void movePlayer(Vec3d destination, EntityPlayer player, boolean keepMomentum) {

        player.setPositionAndUpdate(destination.x, destination.y, destination.z);

        if(keepMomentum) {
            Vec3d velocity = player.getLookVec();
            velocity = velocity.scale(0.25);
            SPacketEntityVelocity p = new SPacketEntityVelocity(player.getEntityId(), velocity.x, velocity.y, velocity.z);
            ((EntityPlayerMP) player).connection.sendPacket(p);
        }
    }
项目:Wizardry    文件:ModuleEffectAntiGravityWell.java   
@Override
@SuppressWarnings("unused")
public boolean run(@Nonnull SpellData spell) {
    World world = spell.world;
    Vec3d position = spell.getData(TARGET_HIT);
    Entity caster = spell.getData(CASTER);

    if (position == null) return false;

    double strength = getModifier(spell, Attributes.AREA, 3, 16);

    for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(new BlockPos(position)).grow(strength, strength, strength))) {
        if (entity == null) continue;
        double dist = entity.getPositionVector().distanceTo(position);
        if (dist < 2) continue;
        if (dist > strength) continue;
        if (!tax(this, spell)) return false;

        final double upperMag = getModifier(spell, Attributes.POTENCY, 10, 50) / 100.0;
        final double scale = 3.5;
        double mag = upperMag * (scale * dist / (-scale * dist - 1) + 1);

        Vec3d dir = position.subtract(entity.getPositionVector()).normalize().scale(mag);

        entity.motionX += (dir.x);
        entity.motionY += (dir.y);
        entity.motionZ += (dir.z);
        entity.fallDistance = 0;
        entity.velocityChanged = true;

        spell.addData(ENTITY_HIT, entity);
        if (entity instanceof EntityPlayerMP)
            ((EntityPlayerMP) entity).connection.sendPacket(new SPacketEntityVelocity(entity));
    }

    return true;
}
项目:Wizardry    文件:ModuleEffectGravityWell.java   
@Override
@SuppressWarnings("unused")
public boolean run(@Nonnull SpellData spell) {
    World world = spell.world;
    Vec3d position = spell.getData(TARGET_HIT);
    Entity caster = spell.getData(CASTER);

    if (position == null) return false;

    double strength = getModifier(spell, Attributes.AREA, 16, 32);

    for (Entity entity : world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(new BlockPos(position)).grow(strength, strength, strength))) {
        if (entity == null) continue;
        double dist = entity.getPositionVector().distanceTo(position);
        if (dist < 2) continue;
        if (dist > strength) continue;
        if (!tax(this, spell)) return false;

        final double upperMag = getModifier(spell, Attributes.POTENCY, 10, 50) / 100.0;
        final double scale = 3.5;
        double mag = upperMag * (scale * dist / (-scale * dist - 1) + 1);

        Vec3d dir = position.subtract(entity.getPositionVector()).normalize().scale(mag);

        entity.motionX += (dir.x);
        entity.motionY += (dir.y);
        entity.motionZ += (dir.z);
        entity.fallDistance = 0;
        entity.velocityChanged = true;

        spell.addData(ENTITY_HIT, entity);
        if (entity instanceof EntityPlayerMP)
            ((EntityPlayerMP) entity).connection.sendPacket(new SPacketEntityVelocity(entity));

        runNextModule(spell);
    }

    return true;
}
项目:Wizardry    文件:ModuleEffectLeap.java   
@Override
@SuppressWarnings("unused")
public boolean run(@Nonnull SpellData spell) {
    float yaw = spell.getData(YAW, 0F);
    float pitch = spell.getData(PITCH, 0F);
    Vec3d pos = spell.getData(TARGET_HIT);
    Entity target = spell.getData(ENTITY_HIT);
    Entity caster = spell.getData(CASTER);

    if (target == null) return false;
    if (!(target instanceof EntityLivingBase)) return true;

    Vec3d lookVec = PosUtils.vecFromRotations(pitch, yaw);

    if (!target.hasNoGravity()) {
        double strength = getModifier(spell, Attributes.POTENCY, 1, 64) / 10.0;
        if (!tax(this, spell)) return false;

        if (!target.getEntityData().hasKey("jump_count")) {
            target.getEntityData().setInteger("jump_count", (int) strength);
            target.getEntityData().setInteger("jump_timer", 200);
        }

        target.motionX += lookVec.x;
        target.motionY += 0.65;
        target.motionZ += lookVec.z;

        target.velocityChanged = true;
        target.fallDistance /= getModifier(spell, Attributes.POTENCY, 2, 10);

        if (target instanceof EntityPlayerMP)
            ((EntityPlayerMP) target).connection.sendPacket(new SPacketEntityVelocity(target));
        spell.world.playSound(null, target.getPosition(), ModSounds.FLY, SoundCategory.NEUTRAL, 1, 1);
    }
    return true;
}
项目:Aether-Legacy    文件:ItemGravititeSword.java   
public boolean hitEntity(ItemStack itemstack, EntityLivingBase hitentity, EntityLivingBase player)
{
    if ((hitentity.hurtTime > 0 || hitentity.deathTime > 0))
    {
        hitentity.addVelocity(0.0D, 1.0D, 0.0D);
        itemstack.damageItem(1, player);
    }

    if (hitentity instanceof EntityPlayerMP)
    {
        ((EntityPlayerMP)hitentity).connection.sendPacket(new SPacketEntityVelocity(hitentity));
    }

    return super.hitEntity(itemstack, hitentity, player);
}
项目:ExpandedRailsMod    文件:NetHandlerPlayClient.java   
/**
 * Sets the velocity of the specified entity to the specified value
 */
public void handleEntityVelocity(SPacketEntityVelocity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());

    if (entity != null)
    {
        entity.setVelocity((double)packetIn.getMotionX() / 8000.0D, (double)packetIn.getMotionY() / 8000.0D, (double)packetIn.getMotionZ() / 8000.0D);
    }
}
项目:EnderIO    文件:PacketTravelEvent.java   
private boolean doServerTeleport(@Nonnull Entity toTp, @Nonnull BlockPos pos, int powerUse, boolean conserveMotion, @Nonnull TravelSource source,
    @Nonnull EnumHand hand) {
  EntityPlayer player = toTp instanceof EntityPlayer ? (EntityPlayer) toTp : null;

  TeleportEntityEvent evt = new TeleportEntityEvent(toTp, source, pos, toTp.dimension);
  if (MinecraftForge.EVENT_BUS.post(evt)) {
    return false;
  }
  pos = evt.getTarget();

  SoundHelper.playSound(toTp.world, toTp, source.sound, 1.0F, 1.0F);

  if (player != null) {
    player.setPositionAndUpdate(pos.getX() + 0.5, pos.getY() + 1.1, pos.getZ() + 0.5);
  } else {
    toTp.setPosition(pos.getX(), pos.getY(), pos.getZ());
  }

  SoundHelper.playSound(toTp.world, toTp, source.sound, 1.0F, 1.0F);

  toTp.fallDistance = 0;

  if (player != null) {
    if (conserveMotion) {
      Vector3d velocityVex = Util.getLookVecEio(player);
      SPacketEntityVelocity p = new SPacketEntityVelocity(toTp.getEntityId(), velocityVex.x, velocityVex.y, velocityVex.z);
      ((EntityPlayerMP) player).connection.sendPacket(p);
    }

    if (powerUse > 0) {
      ItemStack heldItem = player.getHeldItem(hand);
      if (heldItem.getItem() instanceof IItemOfTravel) {
        ItemStack item = heldItem.copy();
        ((IItemOfTravel) item.getItem()).extractInternal(item, powerUse);
        player.setHeldItem(hand, item);
      }
    }
  }

  return true;
}
项目:EnderIO    文件:TeleportUtil.java   
public static boolean serverTeleport(@Nonnull Entity entity, @Nonnull BlockPos pos, int targetDim, boolean conserveMotion, @Nonnull TravelSource source) {

    TeleportEntityEvent evt = new TeleportEntityEvent(entity, source, pos, targetDim);
    if (MinecraftForge.EVENT_BUS.post(evt)) {
      return false;
    }

    EntityPlayerMP player = null;
    if (entity instanceof EntityPlayerMP) {
      player = (EntityPlayerMP) entity;
    }
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();

    int from = entity.dimension;
    if (from != targetDim) {
      MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
      WorldServer fromDim = server.worldServerForDimension(from);
      WorldServer toDim = server.worldServerForDimension(targetDim);
      Teleporter teleporter = new TeleporterEIO(toDim);
      // play sound at the dimension we are leaving for others to hear
      SoundHelper.playSound(server.worldServerForDimension(entity.dimension), entity, source.sound, 1.0F, 1.0F);
      if (player != null) {
        server.getPlayerList().transferPlayerToDimension(player, targetDim, teleporter);
        if (from == 1 && entity.isEntityAlive()) { // get around vanilla End
                                                   // hacks
          toDim.spawnEntity(entity);
          toDim.updateEntityWithOptionalForce(entity, false);
        }
      } else {
        NBTTagCompound tagCompound = new NBTTagCompound();
        float rotationYaw = entity.rotationYaw;
        float rotationPitch = entity.rotationPitch;
        entity.writeToNBT(tagCompound);
        Class<? extends Entity> entityClass = entity.getClass();
        fromDim.removeEntity(entity);

        try {
          Entity newEntity = entityClass.getConstructor(World.class).newInstance(toDim);
          newEntity.readFromNBT(tagCompound);
          newEntity.setLocationAndAngles(x, y, z, rotationYaw, rotationPitch);
          newEntity.forceSpawn = true;
          toDim.spawnEntity(newEntity);
          newEntity.forceSpawn = false; // necessary?
        } catch (Exception e) {
          // Throwables.propagate(e);
          Log.error("serverTeleport: Error creating a entity to be created in new dimension.");
          return false;
        }
      }
    }

    // Force the chunk to load
    if (!entity.world.isBlockLoaded(pos)) {
      entity.world.getChunkFromBlockCoords(pos);
    }

    if (player != null) {
      player.connection.setPlayerLocation(x + 0.5, y + 1.1, z + 0.5, player.rotationYaw, player.rotationPitch);
    } else {
      entity.setPositionAndUpdate(x + 0.5, y + 1.1, z + 0.5);
    }

    entity.fallDistance = 0;
    SoundHelper.playSound(entity.world, entity, source.sound, 1.0F, 1.0F);

    if (player != null) {
      if (conserveMotion) {
        Vector3d velocityVex = Util.getLookVecEio(player);
        SPacketEntityVelocity p = new SPacketEntityVelocity(entity.getEntityId(), velocityVex.x, velocityVex.y, velocityVex.z);
        player.connection.sendPacket(p);
      }
    }

    return true;
  }
项目:Backmemed    文件:INetHandlerPlayClient.java   
/**
 * Sets the velocity of the specified entity to the specified value
 */
void handleEntityVelocity(SPacketEntityVelocity packetIn);
项目:CustomWorldGen    文件:INetHandlerPlayClient.java   
/**
 * Sets the velocity of the specified entity to the specified value
 */
void handleEntityVelocity(SPacketEntityVelocity packetIn);