本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.moveEntity方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.moveEntity方法的具体用法?Java EntityPlayer.moveEntity怎么用?Java EntityPlayer.moveEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.moveEntity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: predictPlayerLocation
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public Vec3 predictPlayerLocation(EntityPlayer player, int ticksIntoFuture) {
if (playerPositions.containsKey(player)) {
List<Vec3> pastPositions = playerPositions.get(player);
if (pastPositions.size() > 1) {
Vec3 first = pastPositions.get(0);
List<Vec3> deltas = new LinkedList<>();
Vec3 previous = first;
for (Vec3 position : pastPositions) {
deltas.add(position.subtract(previous));
previous = position;
}
Vec3 mean = Vec3.ORIGIN;
for (Vec3 delta : deltas)
mean = mean.add(delta);
mean = mean.divideElements(deltas.size());
EntityPlayer simulated = new EntityOtherPlayerMP(mc.theWorld, player.getGameProfile());
simulated.noClip = false;
simulated.setPosition(player.posX, player.posY, player.posZ);
for (int i = 0; i < ticksIntoFuture; i++) {
double x = mean.x, y = mean.y, z = mean.z;
simulated.moveEntity(x, y, z);
if (!player.capabilities.isFlying) {
y = y * 0.8 - 0.02;
}
if (simulated.onGround && y < 0) {
y = 0;
}
x *= 0.99;
z *= 0.99;
mean = new Vec3(x, y, z);
}
return new Vec3(simulated.posX, simulated.posY, simulated.posZ);
}
}
return null;
}