本文整理了Java中net.minecraft.entity.Entity.setWorld()
方法的一些代码示例,展示了Entity.setWorld()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.setWorld()
方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:setWorld
暂无
代码示例来源:origin: CoFH/CoFHCore
public static void transferEntityToWorld(Entity entity, double x, double y, double z, WorldServer oldWorld, WorldServer newWorld) {
oldWorld.profiler.startSection("placing");
x = MathHelper.clamp(x, -29999872, 29999872);
z = MathHelper.clamp(z, -29999872, 29999872);
if (entity.isEntityAlive()) {
entity.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);
newWorld.spawnEntity(entity);
newWorld.updateEntityWithOptionalForce(entity, false);
}
oldWorld.profiler.endSection();
entity.setWorld(newWorld);
}
代码示例来源:origin: Darkhax-Minecraft/Bookshelf
/**
* Changes the world that an entity is in. This allows for changing dimensions safer when
* working with other mods.
*
* @param entity The entity to change the world of.
* @param worldOld The old entity world.
* @param worldNew The new entity world.
*/
public static void changeWorld (Entity entity, WorldServer worldOld, WorldServer worldNew) {
final WorldProvider providerOld = worldOld.provider;
final WorldProvider providerNew = worldNew.provider;
final double moveFactor = providerOld.getMovementFactor() / providerNew.getMovementFactor();
final double x = MathHelper.clamp(entity.posX * moveFactor, -29999872, 29999872);
final double z = MathHelper.clamp(entity.posZ * moveFactor, -29999872, 29999872);
if (entity.isEntityAlive()) {
entity.setLocationAndAngles(x, entity.posY, z, entity.rotationYaw, entity.rotationPitch);
worldNew.spawnEntity(entity);
worldNew.updateEntityWithOptionalForce(entity, false);
}
entity.setWorld(worldNew);
}
代码示例来源:origin: CoFH/CoFHCore
public static void transferEntityToWorld(Entity entity, WorldServer oldWorld, WorldServer newWorld) {
WorldProvider pOld = oldWorld.provider;
WorldProvider pNew = newWorld.provider;
double moveFactor = pOld.getMovementFactor() / pNew.getMovementFactor();
double x = entity.posX * moveFactor;
double z = entity.posZ * moveFactor;
oldWorld.profiler.startSection("placing");
x = MathHelper.clamp(x, -29999872, 29999872);
z = MathHelper.clamp(z, -29999872, 29999872);
if (entity.isEntityAlive()) {
entity.setLocationAndAngles(x, entity.posY, z, entity.rotationYaw, entity.rotationPitch);
newWorld.spawnEntity(entity);
newWorld.updateEntityWithOptionalForce(entity, false);
}
oldWorld.profiler.endSection();
entity.setWorld(newWorld);
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
teleportedEntity.forceSpawn = true;
newWorld.spawnEntity(teleportedEntity);
teleportedEntity.setWorld(newWorld);
teleportedEntity.timeUntilPortal = teleportedEntity instanceof EntityPlayer ? 150 : 20;
代码示例来源:origin: WayofTime/BloodMagic
teleportedEntity.forceSpawn = true;
newWorldServer.spawnEntity(teleportedEntity);
teleportedEntity.setWorld(newWorldServer);
内容来源于网络,如有侵权,请联系作者删除!