本文整理汇总了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);
}