本文整理匯總了Java中net.minecraft.world.storage.WorldInfo.getSpawnX方法的典型用法代碼示例。如果您正苦於以下問題:Java WorldInfo.getSpawnX方法的具體用法?Java WorldInfo.getSpawnX怎麽用?Java WorldInfo.getSpawnX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.world.storage.WorldInfo
的用法示例。
在下文中一共展示了WorldInfo.getSpawnX方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: teleport
import net.minecraft.world.storage.WorldInfo; //導入方法依賴的package包/類
public void teleport(Entity entity, World world) {
EntityPlayerMP playerMP = (EntityPlayerMP) entity;
double dx = 0;
double dy = 0;
double dz = 0;
WorldInfo wi = worldserver.getWorldInfo();
if (wi != null) {
dx = wi.getSpawnX();
dy = wi.getSpawnY();
dz = wi.getSpawnZ();
}
// check for zeros
if (dx == 0 && dy == 0 && dz == 0) {
// Set height to something big
dy = 250;
// Drop down until find solid
while (world.getBlockState(new BlockPos((int) dx, (int) dy - 1, (int) dz)).equals(Blocks.AIR.getDefaultState()) && dy > 0) {
dy--;
}
// Last check if dy == 0
if (dy == 0) {
dy = 128;
}
}
// Offset locations for accuracy
dx = dx + 0.5d;
dy = dy + 1.0d;
dz = dz + 0.5d;
entity.setPosition(dx, dy, dz);
// Freeze motion
entity.motionX = entity.motionY = entity.motionZ = 0.0D;
playerMP.setPosition(dx, dy, dz);
if (playerMP.world.provider.getDimension() != world.provider.getDimension()) {
playerMP.getServer().getPlayerList().transferPlayerToDimension(playerMP, world.provider.getDimension(), this);
}
entity.setPosition(dx, dy, dz);
}