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

项目:harshencastle    文件:HarshenUtils.java   
public static void transferPlayerToDimension(EntityPlayerMP player, int dimensionIn, BlockPos pos, IBlockState state)
{
    int i = player.dimension;
    WorldServer worldserver = player.mcServer.getWorld(player.dimension);
    player.dimension = dimensionIn;
    WorldServer worldserver1 = player.mcServer.getWorld(player.dimension);
    player.connection.sendPacket(new SPacketRespawn(player.dimension, worldserver1.getDifficulty(), worldserver1.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
    player.mcServer.getPlayerList().updatePermissionLevel(player);
    worldserver.removeEntityDangerously(player);
    player.isDead = false;
    transferPlayerToWorld(player, i, worldserver, worldserver1, pos, state);
    player.mcServer.getPlayerList().preparePlayer(player, worldserver);
    player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
    player.interactionManager.setWorld(worldserver1);
    player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities));
    player.mcServer.getPlayerList().updateTimeAndWeatherForPlayer(player, worldserver1);
    player.mcServer.getPlayerList().syncPlayerInventory(player);

    for (PotionEffect potioneffect : player.getActivePotionEffects())
    {
        player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect));
    }
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, i, dimensionIn);
}
项目:Zombe-Modpack    文件:NetHandlerPlayClient.java   
public void handleEntityEffect(SPacketEntityEffect packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

    if (entity instanceof EntityLivingBase)
    {
        Potion potion = Potion.getPotionById(packetIn.getEffectId());

        if (potion != null)
        {
            PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), packetIn.getAmplifier(), packetIn.getIsAmbient(), packetIn.doesShowParticles());
            potioneffect.setPotionDurationMax(packetIn.isMaxDuration());
            ((EntityLivingBase)entity).addPotionEffect(potioneffect);
        }
    }
}
项目:Backmemed    文件:NetHandlerPlayClient.java   
public void handleEntityEffect(SPacketEntityEffect packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

    if (entity instanceof EntityLivingBase)
    {
        Potion potion = Potion.getPotionById(packetIn.getEffectId());

        if (potion != null)
        {
            PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), packetIn.getAmplifier(), packetIn.getIsAmbient(), packetIn.doesShowParticles());
            potioneffect.setPotionDurationMax(packetIn.isMaxDuration());
            ((EntityLivingBase)entity).addPotionEffect(potioneffect);
        }
    }
}
项目:Backmemed    文件:PlayerList.java   
public void changePlayerDimension(EntityPlayerMP player, int dimensionIn)
{
    int i = player.dimension;
    WorldServer worldserver = this.mcServer.worldServerForDimension(player.dimension);
    player.dimension = dimensionIn;
    WorldServer worldserver1 = this.mcServer.worldServerForDimension(player.dimension);
    player.connection.sendPacket(new SPacketRespawn(player.dimension, player.world.getDifficulty(), player.world.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
    this.updatePermissionLevel(player);
    worldserver.removeEntityDangerously(player);
    player.isDead = false;
    this.transferEntityToWorld(player, i, worldserver, worldserver1);
    this.preparePlayer(player, worldserver);
    player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
    player.interactionManager.setWorld(worldserver1);
    player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities));
    this.updateTimeAndWeatherForPlayer(player, worldserver1);
    this.syncPlayerInventory(player);

    for (PotionEffect potioneffect : player.getActivePotionEffects())
    {
        player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect));
    }
}
项目:CustomWorldGen    文件:NetHandlerPlayClient.java   
public void handleEntityEffect(SPacketEntityEffect packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

    if (entity instanceof EntityLivingBase)
    {
        Potion potion = Potion.getPotionById(packetIn.getEffectId() & 0xFF);

        if (potion != null)
        {
            PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), packetIn.getAmplifier(), packetIn.getIsAmbient(), packetIn.doesShowParticles());
            potioneffect.setPotionDurationMax(packetIn.isMaxDuration());
            ((EntityLivingBase)entity).addPotionEffect(potioneffect);
        }
    }
}
项目:CustomWorldGen    文件:PlayerList.java   
public void transferPlayerToDimension(EntityPlayerMP player, int dimensionIn, net.minecraft.world.Teleporter teleporter)
{
    int i = player.dimension;
    WorldServer worldserver = this.mcServer.worldServerForDimension(player.dimension);
    player.dimension = dimensionIn;
    WorldServer worldserver1 = this.mcServer.worldServerForDimension(player.dimension);
    player.connection.sendPacket(new SPacketRespawn(player.dimension, worldserver1.getDifficulty(), worldserver1.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
    this.updatePermissionLevel(player);
    worldserver.removeEntityDangerously(player);
    player.isDead = false;
    this.transferEntityToWorld(player, i, worldserver, worldserver1, teleporter);
    this.preparePlayer(player, worldserver);
    player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
    player.interactionManager.setWorld(worldserver1);
    player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities));
    this.updateTimeAndWeatherForPlayer(player, worldserver1);
    this.syncPlayerInventory(player);

    for (PotionEffect potioneffect : player.getActivePotionEffects())
    {
        player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect));
    }
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, i, dimensionIn);
}
项目:ExpandedRailsMod    文件:NetHandlerPlayClient.java   
public void handleEntityEffect(SPacketEntityEffect packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

    if (entity instanceof EntityLivingBase)
    {
        Potion potion = Potion.getPotionById(packetIn.getEffectId() & 0xFF);

        if (potion != null)
        {
            PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), packetIn.getAmplifier(), packetIn.getIsAmbient(), packetIn.doesShowParticles());
            potioneffect.setPotionDurationMax(packetIn.isMaxDuration());
            ((EntityLivingBase)entity).addPotionEffect(potioneffect);
        }
    }
}
项目:LittleThings-old    文件:CommandDimTeleport.java   
private Entity teleportPlayerToDim(World oldWorld, int newWorldID, double d, double e, double f, Entity entity)
{
    MinecraftServer server = entity.getServer();
    WorldServer oldWorldServer = server.worldServerForDimension(entity.dimension);
    WorldServer newWorldServer = server.worldServerForDimension(newWorldID);
    if (entity instanceof EntityPlayer) {
        EntityPlayerMP player = (EntityPlayerMP) entity;
        if (!player.worldObj.isRemote) {
            player.worldObj.theProfiler.startSection("portal");
            player.worldObj.theProfiler.startSection("changeDimension");
            PlayerList config = player.mcServer.getPlayerList();
            player.closeScreen();
            player.dimension = newWorldServer.provider.getDimension();
            player.playerNetServerHandler.sendPacket(new SPacketRespawn(player.dimension, player.worldObj.getDifficulty(), newWorldServer.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
            oldWorldServer.removeEntity(player);
            player.isDead = false;
            player.setLocationAndAngles(d, e, f, player.rotationYaw, player.rotationPitch);
            newWorldServer.spawnEntityInWorld(player);
            player.setWorld(newWorldServer);
            config.preparePlayer(player, oldWorldServer);
            player.playerNetServerHandler.setPlayerLocation(d, e, f, entity.rotationYaw, entity.rotationPitch);
            player.interactionManager.setWorld(newWorldServer);
            config.updateTimeAndWeatherForPlayer(player, newWorldServer);
            config.syncPlayerInventory(player);
            player.worldObj.theProfiler.endSection();
            oldWorldServer.resetUpdateEntityTick();
            newWorldServer.resetUpdateEntityTick();
            player.worldObj.theProfiler.endSection();
            for (PotionEffect potionEffect : player.getActivePotionEffects()) {
                player.playerNetServerHandler.sendPacket(new SPacketEntityEffect(player.getEntityId(), potionEffect));
            }
            player.playerNetServerHandler.sendPacket(new SPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
            FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldWorldServer.provider.getDimension(), player.dimension);
        }
        player.worldObj.theProfiler.endSection();
        return player;
    }
    return null;
}
项目:morecommands    文件:PatchEntityPlayerMP.java   
private static void transferPlayerToDimension(PlayerList playerList, net.minecraft.entity.player.EntityPlayerMP player, int dimension, Teleporter teleporter) {
    int i = player.dimension;
    WorldServer worldserver = playerList.getServerInstance().getWorld(player.dimension);
    player.dimension = dimension;
    WorldServer worldserver1 = playerList.getServerInstance().getWorld(player.dimension);
    player.connection.sendPacket(new SPacketRespawn(player.dimension, worldserver1.getDifficulty(), worldserver1.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));

    //MoreCommands Bug fix: client world has wrong spawn position, because WorldClient is recreated after receiving S07PacketRespawn
    //with default spawn coordinates 8, 64, 8. This causes e.g. the compass to point to a wrong direction. A possible solution is sending a S05PacketSpawnPosition.
    //Fixes https://bugs.mojang.com/browse/MC-679
    player.connection.sendPacket(new SPacketSpawnPosition(new BlockPos(worldserver1.getWorldInfo().getSpawnX(), worldserver1.getWorldInfo().getSpawnY(), worldserver1.getWorldInfo().getSpawnZ())));

    playerList.updatePermissionLevel(player);
    worldserver.removeEntityDangerously(player);
    player.isDead = false;
    playerList.transferEntityToWorld(player, i, worldserver, worldserver1, teleporter);
    playerList.preparePlayer(player, worldserver);
    player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
    player.interactionManager.setWorld(worldserver1);
    player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities));
    playerList.updateTimeAndWeatherForPlayer(player, worldserver1);
    playerList.syncPlayerInventory(player);

    for (PotionEffect potioneffect : player.getActivePotionEffects())
    {
        player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect));
    }
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, i, dimension);
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
protected void onNewPotionEffect(PotionEffect id)
{
    super.onNewPotionEffect(id);
    this.connection.sendPacket(new SPacketEntityEffect(this.getEntityId(), id));
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
protected void onChangedPotionEffect(PotionEffect id, boolean p_70695_2_)
{
    super.onChangedPotionEffect(id, p_70695_2_);
    this.connection.sendPacket(new SPacketEntityEffect(this.getEntityId(), id));
}
项目:Backmemed    文件:EntityPlayerMP.java   
protected void onNewPotionEffect(PotionEffect id)
{
    super.onNewPotionEffect(id);
    this.connection.sendPacket(new SPacketEntityEffect(this.getEntityId(), id));
}
项目:Backmemed    文件:EntityPlayerMP.java   
protected void onChangedPotionEffect(PotionEffect id, boolean p_70695_2_)
{
    super.onChangedPotionEffect(id, p_70695_2_);
    this.connection.sendPacket(new SPacketEntityEffect(this.getEntityId(), id));
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
protected void onNewPotionEffect(PotionEffect id)
{
    super.onNewPotionEffect(id);
    this.connection.sendPacket(new SPacketEntityEffect(this.getEntityId(), id));
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
protected void onChangedPotionEffect(PotionEffect id, boolean p_70695_2_)
{
    super.onChangedPotionEffect(id, p_70695_2_);
    this.connection.sendPacket(new SPacketEntityEffect(this.getEntityId(), id));
}
项目:minecraft-territorialdealings    文件:Transition.java   
static void transferPlayerToDimension(EntityPlayerMP player, int dimensionTo, int targetHeight)
  {
if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(player, dimensionTo)) { return; } // Moving that here, to consolidate these functions.

net.minecraft.world.Teleporter teleporter = player.mcServer.worldServerForDimension(dimensionTo).getDefaultTeleporter();
PlayerList playerList = player.mcServer.getPlayerList();

      int dimensionFrom = player.dimension;

      // Changing dimensions...
      WorldServer wsPrev = player.mcServer.worldServerForDimension(player.dimension);

      player.dimension = dimensionTo;

      WorldServer wsNew = player.mcServer.worldServerForDimension(player.dimension);

      // Respawn? Used to recreate the player entity.
      player.connection.sendPacket(new SPacketRespawn(player.dimension, wsNew.getDifficulty(), wsNew.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));

      // Capabilities...
      playerList.updatePermissionLevel(player);

      // Begone from the old world?
      wsPrev.removeEntity(player);

      // Safety, I suppose.
      player.isDead = false;

      // We haven't reached the "set portal" level yet. Going deeper.
      transferEntityToWorld(player, dimensionFrom, wsPrev, wsNew, teleporter, targetHeight);

      // Getting chunks ready?
      playerList.preparePlayer(player, wsPrev);

      // Inserting their new position here? May not be necessary, since this is called by the drop and transfer, which sets the position beforehand and afterwards.
      player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);

      // More formalities...
      player.interactionManager.setWorld(wsNew);
      player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities));

      playerList.updateTimeAndWeatherForPlayer(player, wsNew);
      playerList.syncPlayerInventory(player);

      // Reapplying potion effects
      for (PotionEffect potioneffect : player.getActivePotionEffects())
      {
          player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect));
      }

      // We're done.
      net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, dimensionFrom, dimensionTo);
  }
项目:CrystalMod    文件:TeleportUtil.java   
private static EntityPlayer teleportPlayerToDim(EntityPlayerMP player, MinecraftServer server, int sourceDim, int targetDim, double xCoord, double yCoord, double zCoord, float yaw, float pitch, Vector3d motion) {
    WorldServer sourceWorld = server.worldServerForDimension(sourceDim);
    WorldServer targetWorld = server.worldServerForDimension(targetDim);
    PlayerList playerList = server.getPlayerList();

    player.dimension = targetDim;
    player.connection.sendPacket(new SPacketRespawn(player.dimension, targetWorld.getDifficulty(), targetWorld.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
    playerList.updatePermissionLevel(player);
    sourceWorld.removeEntityDangerously(player);
    player.isDead = false;

    //region Transfer to world

    player.setLocationAndAngles(xCoord, yCoord, zCoord, yaw, pitch);
    player.connection.setPlayerLocation(xCoord, yCoord, zCoord, yaw, pitch);
    targetWorld.spawnEntity(player);
    targetWorld.updateEntityWithOptionalForce(player, false);
    player.setWorld(targetWorld);

    //endregion

    playerList.preparePlayer(player, sourceWorld);
    player.connection.setPlayerLocation(xCoord, yCoord, zCoord, yaw, pitch);
    player.interactionManager.setWorld(targetWorld);
    player.connection.sendPacket(new SPacketPlayerAbilities(player.capabilities));

    playerList.updateTimeAndWeatherForPlayer(player, targetWorld);
    playerList.syncPlayerInventory(player);

    for (PotionEffect potioneffect : player.getActivePotionEffects()) {
        player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect));
    }
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, sourceDim, targetDim);
    player.setLocationAndAngles(xCoord, yCoord, zCoord, yaw, pitch);

    player.motionX += motion.x; player.motionY += motion.y; player.motionZ += motion.z;
    NBTTagCompound nbt = new NBTTagCompound();
    nbt.setDouble("X", motion.x);
    nbt.setDouble("Y", motion.y);
    nbt.setDouble("Z", motion.z);
    CrystalModNetwork.sendToAll(new PacketEntityMessage(player, "AddMotion", nbt));

    return player;
}
项目:Bookshelf    文件:PlayerUtils.java   
/**
 * Changes the dimension a player is in, in a safe way. This will make sure the player is
 * teleported to the dimension and all the correct packets are sent to keep the client in
 * sync. It also gets around teleporter code which in some cases will crash the server.
 *
 * @param player The player to change the dimension of.
 * @param dimension The dimension to send the player to.
 * @param playerData The player data from the server.
 */
public static void changeDimension (EntityPlayerMP player, int dimension, PlayerList playerData) {

    if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(player, dimension)) {

        return;
    }

    final int oldDim = player.dimension;
    final boolean wasAlive = player.isEntityAlive();
    final WorldServer worldOld = playerData.getServerInstance().getWorld(player.dimension);
    final WorldServer worldNew = playerData.getServerInstance().getWorld(dimension);

    if (player.isBeingRidden()) {

        player.removePassengers();
    }

    if (player.isRiding()) {

        player.dismountRidingEntity();
    }

    player.dimension = dimension;
    player.connection.sendPacket(new SPacketRespawn(player.dimension, player.world.getDifficulty(), player.world.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
    worldOld.removeEntityDangerously(player);

    EntityUtils.changeWorld(player, worldOld, worldNew);
    playerData.preparePlayer(player, worldOld);
    player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
    player.interactionManager.setWorld(worldNew);
    playerData.updateTimeAndWeatherForPlayer(player, worldNew);
    playerData.syncPlayerInventory(player);

    if (player.isDead && wasAlive) {

        player.isDead = false;
    }

    for (final PotionEffect potioneffect : player.getActivePotionEffects()) {

        player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect));
    }

    FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldDim, dimension);
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
protected void onNewPotionEffect(PotionEffect id)
{
    super.onNewPotionEffect(id);
    this.connection.sendPacket(new SPacketEntityEffect(this.getEntityId(), id));
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
protected void onChangedPotionEffect(PotionEffect id, boolean p_70695_2_)
{
    super.onChangedPotionEffect(id, p_70695_2_);
    this.connection.sendPacket(new SPacketEntityEffect(this.getEntityId(), id));
}
项目:Backmemed    文件:INetHandlerPlayClient.java   
void handleEntityEffect(SPacketEntityEffect packetIn);
项目:CustomWorldGen    文件:INetHandlerPlayClient.java   
void handleEntityEffect(SPacketEntityEffect packetIn);