本文整理匯總了Java中net.minecraft.entity.EntityLivingBase.setPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityLivingBase.setPosition方法的具體用法?Java EntityLivingBase.setPosition怎麽用?Java EntityLivingBase.setPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.setPosition方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: teleportTo
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
private static boolean teleportTo(EntityLivingBase entity, double xx, double yy, double zz) {
EnderTeleportEvent event = new EnderTeleportEvent(entity, xx, yy, zz, 0);
if (MinecraftForge.EVENT_BUS.post(event))
return false;
double d3 = entity.posX;
double d4 = entity.posY;
double d5 = entity.posZ;
entity.posX = event.targetX;
entity.posY = event.targetY;
entity.posZ = event.targetZ;
boolean flag = false;
int i = MathHelper.floor_double(entity.posX);
int j = MathHelper.floor_double(entity.posY);
int k = MathHelper.floor_double(entity.posZ);
if (entity.worldObj.blockExists(i, j, k)) {
boolean flag1 = false;
while (!flag1 && j > 0) {
Block block = entity.worldObj.getBlock(i, j - 1, k);
if (block.getMaterial().blocksMovement())
flag1 = true;
else {
entity.posY--;
j--;
}
}
if (flag1) {
entity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ);
if (entity.worldObj.getCollidingBoundingBoxes(entity, entity.boundingBox).isEmpty() && !entity.worldObj.isAnyLiquid(entity.boundingBox))
flag = true;
}
}
if (!flag) {
entity.setPosition(d3, d4, d5);
return false;
} else {
short short1 = 128;
for (int l = 0; l < short1; l++) {
double d6 = l / (short1 - 1.0D);
float f = (entity.getRNG().nextFloat() - 0.5F) * 0.2F;
float f1 = (entity.getRNG().nextFloat() - 0.5F) * 0.2F;
float f2 = (entity.getRNG().nextFloat() - 0.5F) * 0.2F;
double d7 = d3 + (entity.posX - d3) * d6 + (entity.getRNG().nextDouble() - 0.5D) * entity.width * 2.0D;
double d8 = d4 + (entity.posY - d4) * d6 + entity.getRNG().nextDouble() * entity.height;
double d9 = d5 + (entity.posZ - d5) * d6 + (entity.getRNG().nextDouble() - 0.5D) * entity.width * 2.0D;
entity.worldObj.spawnParticle("portal", d7, d8, d9, f, f1, f2);
}
entity.worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F);
entity.playSound("mob.endermen.portal", 1.0F, 1.0F);
return true;
}
}
示例2: setEntitySize
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
public static void setEntitySize(EntityLivingBase ent, float height, float health) {
ent.width *= height / ent.height;
ent.height = height;
setHealth(ent, health);
ent.setPosition(ent.posX, ent.posY, ent.posZ);
}