本文整理匯總了Java中net.minecraft.world.WorldServer.spawnEntityInWorld方法的典型用法代碼示例。如果您正苦於以下問題:Java WorldServer.spawnEntityInWorld方法的具體用法?Java WorldServer.spawnEntityInWorld怎麽用?Java WorldServer.spawnEntityInWorld使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.world.WorldServer
的用法示例。
在下文中一共展示了WorldServer.spawnEntityInWorld方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: playerLoggedIn
import net.minecraft.world.WorldServer; //導入方法依賴的package包/類
/**
* Called when a player successfully logs in. Reads player data from disk and inserts the player into the world.
*/
public void playerLoggedIn(EntityPlayerMP playerIn)
{
this.playerEntityList.add(playerIn);
this.uuidToPlayerMap.put(playerIn.getUniqueID(), playerIn);
this.sendPacketToAllPlayers(new S38PacketPlayerListItem(S38PacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {playerIn}));
WorldServer worldserver = this.mcServer.worldServerForDimension(playerIn.dimension);
worldserver.spawnEntityInWorld(playerIn);
this.preparePlayer(playerIn, (WorldServer)null);
for (int i = 0; i < this.playerEntityList.size(); ++i)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(i);
playerIn.playerNetServerHandler.sendPacket(new S38PacketPlayerListItem(S38PacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {entityplayermp}));
}
}
示例2: playerLoggedIn
import net.minecraft.world.WorldServer; //導入方法依賴的package包/類
/**
* Called when a player successfully logs in. Reads player data from disk and inserts the player into the world.
*/
public void playerLoggedIn(EntityPlayerMP playerIn)
{
this.playerEntityList.add(playerIn);
this.uuidToPlayerMap.put(playerIn.getUniqueID(), playerIn);
this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {playerIn}));
WorldServer worldserver = this.mcServer.worldServerForDimension(playerIn.dimension);
for (int i = 0; i < this.playerEntityList.size(); ++i)
{
playerIn.connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {(EntityPlayerMP)this.playerEntityList.get(i)}));
}
net.minecraftforge.common.chunkio.ChunkIOExecutor.adjustPoolSize(this.getCurrentPlayerCount());
worldserver.spawnEntityInWorld(playerIn);
this.preparePlayer(playerIn, (WorldServer)null);
}
示例3: playerLoggedIn
import net.minecraft.world.WorldServer; //導入方法依賴的package包/類
/**
* Called when a player successfully logs in. Reads player data from disk and inserts the player into the world.
*/
public void playerLoggedIn(EntityPlayerMP playerIn)
{
this.playerEntityList.add(playerIn);
this.uuidToPlayerMap.put(playerIn.getUniqueID(), playerIn);
this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {playerIn}));
WorldServer worldserver = this.mcServer.worldServerForDimension(playerIn.dimension);
for (int i = 0; i < this.playerEntityList.size(); ++i)
{
playerIn.connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {(EntityPlayerMP)this.playerEntityList.get(i)}));
}
worldserver.spawnEntityInWorld(playerIn);
this.preparePlayer(playerIn, (WorldServer)null);
}
示例4: travelToDimension
import net.minecraft.world.WorldServer; //導入方法依賴的package包/類
/**
* Teleports the entity to another dimension. Params: Dimension number to teleport to
*/
public void travelToDimension(int dimensionId)
{
if (!this.worldObj.isRemote && !this.isDead)
{
this.worldObj.theProfiler.startSection("changeDimension");
MinecraftServer minecraftserver = MinecraftServer.getServer();
int i = this.dimension;
WorldServer worldserver = minecraftserver.worldServerForDimension(i);
WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimensionId);
this.dimension = dimensionId;
if (i == 1 && dimensionId == 1)
{
worldserver1 = minecraftserver.worldServerForDimension(0);
this.dimension = 0;
}
this.worldObj.removeEntity(this);
this.isDead = false;
this.worldObj.theProfiler.startSection("reposition");
minecraftserver.getConfigurationManager().transferEntityToWorld(this, i, worldserver, worldserver1);
this.worldObj.theProfiler.endStartSection("reloading");
Entity entity = EntityList.createEntityByName(EntityList.getEntityString(this), worldserver1);
if (entity != null)
{
entity.copyDataFromOld(this);
if (i == 1 && dimensionId == 1)
{
BlockPos blockpos = this.worldObj.getTopSolidOrLiquidBlock(worldserver1.getSpawnPoint());
entity.moveToBlockPosAndAngles(blockpos, entity.rotationYaw, entity.rotationPitch);
}
worldserver1.spawnEntityInWorld(entity);
}
this.isDead = true;
this.worldObj.theProfiler.endSection();
worldserver.resetUpdateEntityTick();
worldserver1.resetUpdateEntityTick();
this.worldObj.theProfiler.endSection();
}
}
示例5: handleSpectate
import net.minecraft.world.WorldServer; //導入方法依賴的package包/類
public void handleSpectate(C18PacketSpectate packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());
if (this.playerEntity.isSpectator())
{
Entity entity = null;
for (WorldServer worldserver : this.serverController.worldServers)
{
if (worldserver != null)
{
entity = packetIn.getEntity(worldserver);
if (entity != null)
{
break;
}
}
}
if (entity != null)
{
this.playerEntity.setSpectatingEntity(this.playerEntity);
this.playerEntity.mountEntity((Entity)null);
if (entity.worldObj != this.playerEntity.worldObj)
{
WorldServer worldserver1 = this.playerEntity.getServerForPlayer();
WorldServer worldserver2 = (WorldServer)entity.worldObj;
this.playerEntity.dimension = entity.dimension;
this.sendPacket(new S07PacketRespawn(this.playerEntity.dimension, worldserver1.getDifficulty(), worldserver1.getWorldInfo().getTerrainType(), this.playerEntity.theItemInWorldManager.getGameType()));
worldserver1.removePlayerEntityDangerously(this.playerEntity);
this.playerEntity.isDead = false;
this.playerEntity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if (this.playerEntity.isEntityAlive())
{
worldserver1.updateEntityWithOptionalForce(this.playerEntity, false);
worldserver2.spawnEntityInWorld(this.playerEntity);
worldserver2.updateEntityWithOptionalForce(this.playerEntity, false);
}
this.playerEntity.setWorld(worldserver2);
this.serverController.getConfigurationManager().preparePlayer(this.playerEntity, worldserver1);
this.playerEntity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ);
this.playerEntity.theItemInWorldManager.setWorld(worldserver2);
this.serverController.getConfigurationManager().updateTimeAndWeatherForPlayer(this.playerEntity, worldserver2);
this.serverController.getConfigurationManager().syncPlayerInventory(this.playerEntity);
}
else
{
this.playerEntity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ);
}
}
}
}
示例6: transferEntityToWorld
import net.minecraft.world.WorldServer; //導入方法依賴的package包/類
@SuppressWarnings("unused")
public void transferEntityToWorld(Entity entityIn, int lastDimension, WorldServer oldWorldIn, WorldServer toWorldIn, net.minecraft.world.Teleporter teleporter)
{
net.minecraft.world.WorldProvider pOld = oldWorldIn.provider;
net.minecraft.world.WorldProvider pNew = toWorldIn.provider;
double moveFactor = pOld.getMovementFactor() / pNew.getMovementFactor();
double d0 = entityIn.posX * moveFactor;
double d1 = entityIn.posZ * moveFactor;
double d2 = 8.0D;
float f = entityIn.rotationYaw;
oldWorldIn.theProfiler.startSection("moving");
if (false && entityIn.dimension == -1)
{
d0 = MathHelper.clamp_double(d0 / 8.0D, toWorldIn.getWorldBorder().minX() + 16.0D, toWorldIn.getWorldBorder().maxX() - 16.0D);
d1 = MathHelper.clamp_double(d1 / 8.0D, toWorldIn.getWorldBorder().minZ() + 16.0D, toWorldIn.getWorldBorder().maxZ() - 16.0D);
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
if (entityIn.isEntityAlive())
{
oldWorldIn.updateEntityWithOptionalForce(entityIn, false);
}
}
else if (false && entityIn.dimension == 0)
{
d0 = MathHelper.clamp_double(d0 * 8.0D, toWorldIn.getWorldBorder().minX() + 16.0D, toWorldIn.getWorldBorder().maxX() - 16.0D);
d1 = MathHelper.clamp_double(d1 * 8.0D, toWorldIn.getWorldBorder().minZ() + 16.0D, toWorldIn.getWorldBorder().maxZ() - 16.0D);
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
if (entityIn.isEntityAlive())
{
oldWorldIn.updateEntityWithOptionalForce(entityIn, false);
}
}
if (entityIn.dimension == 1)
{
BlockPos blockpos;
if (lastDimension == 1)
{
blockpos = toWorldIn.getSpawnPoint();
}
else
{
blockpos = toWorldIn.getSpawnCoordinate();
}
d0 = (double)blockpos.getX();
entityIn.posY = (double)blockpos.getY();
d1 = (double)blockpos.getZ();
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, 90.0F, 0.0F);
if (entityIn.isEntityAlive())
{
oldWorldIn.updateEntityWithOptionalForce(entityIn, false);
}
}
oldWorldIn.theProfiler.endSection();
if (lastDimension != 1)
{
oldWorldIn.theProfiler.startSection("placing");
d0 = (double)MathHelper.clamp_int((int)d0, -29999872, 29999872);
d1 = (double)MathHelper.clamp_int((int)d1, -29999872, 29999872);
if (entityIn.isEntityAlive())
{
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
teleporter.placeInPortal(entityIn, f);
toWorldIn.spawnEntityInWorld(entityIn);
toWorldIn.updateEntityWithOptionalForce(entityIn, false);
}
oldWorldIn.theProfiler.endSection();
}
entityIn.setWorld(toWorldIn);
}
示例7: transferEntityToWorld
import net.minecraft.world.WorldServer; //導入方法依賴的package包/類
/**
* Transfers an entity from a world to another world.
*/
public void transferEntityToWorld(Entity entityIn, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_)
{
double d0 = entityIn.posX;
double d1 = entityIn.posZ;
double d2 = 8.0D;
float f = entityIn.rotationYaw;
p_82448_3_.theProfiler.startSection("moving");
if (entityIn.dimension == -1)
{
d0 = MathHelper.clamp_double(d0 / d2, p_82448_4_.getWorldBorder().minX() + 16.0D, p_82448_4_.getWorldBorder().maxX() - 16.0D);
d1 = MathHelper.clamp_double(d1 / d2, p_82448_4_.getWorldBorder().minZ() + 16.0D, p_82448_4_.getWorldBorder().maxZ() - 16.0D);
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
if (entityIn.isEntityAlive())
{
p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
}
}
else if (entityIn.dimension == 0)
{
d0 = MathHelper.clamp_double(d0 * d2, p_82448_4_.getWorldBorder().minX() + 16.0D, p_82448_4_.getWorldBorder().maxX() - 16.0D);
d1 = MathHelper.clamp_double(d1 * d2, p_82448_4_.getWorldBorder().minZ() + 16.0D, p_82448_4_.getWorldBorder().maxZ() - 16.0D);
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
if (entityIn.isEntityAlive())
{
p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
}
}
else
{
BlockPos blockpos;
if (p_82448_2_ == 1)
{
blockpos = p_82448_4_.getSpawnPoint();
}
else
{
blockpos = p_82448_4_.getSpawnCoordinate();
}
d0 = (double)blockpos.getX();
entityIn.posY = (double)blockpos.getY();
d1 = (double)blockpos.getZ();
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, 90.0F, 0.0F);
if (entityIn.isEntityAlive())
{
p_82448_3_.updateEntityWithOptionalForce(entityIn, false);
}
}
p_82448_3_.theProfiler.endSection();
if (p_82448_2_ != 1)
{
p_82448_3_.theProfiler.startSection("placing");
d0 = (double)MathHelper.clamp_int((int)d0, -29999872, 29999872);
d1 = (double)MathHelper.clamp_int((int)d1, -29999872, 29999872);
if (entityIn.isEntityAlive())
{
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
p_82448_4_.getDefaultTeleporter().placeInPortal(entityIn, f);
p_82448_4_.spawnEntityInWorld(entityIn);
p_82448_4_.updateEntityWithOptionalForce(entityIn, false);
}
p_82448_3_.theProfiler.endSection();
}
entityIn.setWorld(p_82448_4_);
}
示例8: handleSpectate
import net.minecraft.world.WorldServer; //導入方法依賴的package包/類
public void handleSpectate(CPacketSpectate packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
if (this.playerEntity.isSpectator())
{
Entity entity = null;
for (WorldServer worldserver : this.serverController.worldServers)
{
if (worldserver != null)
{
entity = packetIn.getEntity(worldserver);
if (entity != null)
{
break;
}
}
}
if (entity != null)
{
this.playerEntity.setSpectatingEntity(this.playerEntity);
this.playerEntity.dismountRidingEntity();
if (entity.worldObj == this.playerEntity.worldObj)
{
this.playerEntity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ);
}
else
{
WorldServer worldserver1 = this.playerEntity.getServerWorld();
WorldServer worldserver2 = (WorldServer)entity.worldObj;
this.playerEntity.dimension = entity.dimension;
this.sendPacket(new SPacketRespawn(this.playerEntity.dimension, worldserver1.getDifficulty(), worldserver1.getWorldInfo().getTerrainType(), this.playerEntity.interactionManager.getGameType()));
this.serverController.getPlayerList().updatePermissionLevel(this.playerEntity);
worldserver1.removeEntityDangerously(this.playerEntity);
this.playerEntity.isDead = false;
this.playerEntity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if (this.playerEntity.isEntityAlive())
{
worldserver1.updateEntityWithOptionalForce(this.playerEntity, false);
worldserver2.spawnEntityInWorld(this.playerEntity);
worldserver2.updateEntityWithOptionalForce(this.playerEntity, false);
}
this.playerEntity.setWorld(worldserver2);
this.serverController.getPlayerList().preparePlayer(this.playerEntity, worldserver1);
this.playerEntity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ);
this.playerEntity.interactionManager.setWorld(worldserver2);
this.serverController.getPlayerList().updateTimeAndWeatherForPlayer(this.playerEntity, worldserver2);
this.serverController.getPlayerList().syncPlayerInventory(this.playerEntity);
}
}
}
}
示例9: handleSpectate
import net.minecraft.world.WorldServer; //導入方法依賴的package包/類
public void handleSpectate(CPacketSpectate packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
if (this.playerEntity.isSpectator())
{
Entity entity = null;
for (WorldServer worldserver : this.serverController.worldServers)
{
if (worldserver != null)
{
entity = packetIn.getEntity(worldserver);
if (entity != null)
{
break;
}
}
}
if (entity != null)
{
this.playerEntity.setSpectatingEntity(this.playerEntity);
this.playerEntity.dismountRidingEntity();
if (entity.world == this.playerEntity.world)
{
this.playerEntity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ);
}
else
{
WorldServer worldserver1 = this.playerEntity.getServerWorld();
WorldServer worldserver2 = (WorldServer)entity.world;
this.playerEntity.dimension = entity.dimension;
this.sendPacket(new SPacketRespawn(this.playerEntity.dimension, worldserver1.getDifficulty(), worldserver1.getWorldInfo().getTerrainType(), this.playerEntity.interactionManager.getGameType()));
this.serverController.getPlayerList().updatePermissionLevel(this.playerEntity);
worldserver1.removeEntityDangerously(this.playerEntity);
this.playerEntity.isDead = false;
this.playerEntity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if (this.playerEntity.isEntityAlive())
{
worldserver1.updateEntityWithOptionalForce(this.playerEntity, false);
worldserver2.spawnEntityInWorld(this.playerEntity);
worldserver2.updateEntityWithOptionalForce(this.playerEntity, false);
}
this.playerEntity.setWorld(worldserver2);
this.serverController.getPlayerList().preparePlayer(this.playerEntity, worldserver1);
this.playerEntity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ);
this.playerEntity.interactionManager.setWorld(worldserver2);
this.serverController.getPlayerList().updateTimeAndWeatherForPlayer(this.playerEntity, worldserver2);
this.serverController.getPlayerList().syncPlayerInventory(this.playerEntity);
}
}
}
}
示例10: transferEntityToWorld
import net.minecraft.world.WorldServer; //導入方法依賴的package包/類
/**
* Transfers an entity from a world to another world.
*/
public void transferEntityToWorld(Entity entityIn, int lastDimension, WorldServer oldWorldIn, WorldServer toWorldIn)
{
double d0 = entityIn.posX;
double d1 = entityIn.posZ;
double d2 = 8.0D;
float f = entityIn.rotationYaw;
oldWorldIn.theProfiler.startSection("moving");
if (entityIn.dimension == -1)
{
d0 = MathHelper.clamp(d0 / 8.0D, toWorldIn.getWorldBorder().minX() + 16.0D, toWorldIn.getWorldBorder().maxX() - 16.0D);
d1 = MathHelper.clamp(d1 / 8.0D, toWorldIn.getWorldBorder().minZ() + 16.0D, toWorldIn.getWorldBorder().maxZ() - 16.0D);
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
if (entityIn.isEntityAlive())
{
oldWorldIn.updateEntityWithOptionalForce(entityIn, false);
}
}
else if (entityIn.dimension == 0)
{
d0 = MathHelper.clamp(d0 * 8.0D, toWorldIn.getWorldBorder().minX() + 16.0D, toWorldIn.getWorldBorder().maxX() - 16.0D);
d1 = MathHelper.clamp(d1 * 8.0D, toWorldIn.getWorldBorder().minZ() + 16.0D, toWorldIn.getWorldBorder().maxZ() - 16.0D);
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
if (entityIn.isEntityAlive())
{
oldWorldIn.updateEntityWithOptionalForce(entityIn, false);
}
}
else
{
BlockPos blockpos;
if (lastDimension == 1)
{
blockpos = toWorldIn.getSpawnPoint();
}
else
{
blockpos = toWorldIn.getSpawnCoordinate();
}
d0 = (double)blockpos.getX();
entityIn.posY = (double)blockpos.getY();
d1 = (double)blockpos.getZ();
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, 90.0F, 0.0F);
if (entityIn.isEntityAlive())
{
oldWorldIn.updateEntityWithOptionalForce(entityIn, false);
}
}
oldWorldIn.theProfiler.endSection();
if (lastDimension != 1)
{
oldWorldIn.theProfiler.startSection("placing");
d0 = (double)MathHelper.clamp((int)d0, -29999872, 29999872);
d1 = (double)MathHelper.clamp((int)d1, -29999872, 29999872);
if (entityIn.isEntityAlive())
{
entityIn.setLocationAndAngles(d0, entityIn.posY, d1, entityIn.rotationYaw, entityIn.rotationPitch);
toWorldIn.getDefaultTeleporter().placeInPortal(entityIn, f);
toWorldIn.spawnEntityInWorld(entityIn);
toWorldIn.updateEntityWithOptionalForce(entityIn, false);
}
oldWorldIn.theProfiler.endSection();
}
entityIn.setWorld(toWorldIn);
}