本文整理了Java中net.minecraft.entity.Entity.onCollideWithPlayer()
方法的一些代码示例,展示了Entity.onCollideWithPlayer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.onCollideWithPlayer()
方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:onCollideWithPlayer
暂无
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) {
super.onCollideWithPlayer(par1EntityPlayer);
if (!world.isRemote && par1EntityPlayer instanceof EntityPlayerMP && par1EntityPlayer.posY > posY && ((EntityPlayerMP) par1EntityPlayer).collidedVertically) {
EntityPlayerMP player = (EntityPlayerMP) par1EntityPlayer;
/* TODO handle collision with players to allow them flying and disallow once they stop colliding
probably a collection of players in collision with this entity, on update check if they have collided in the last 10? ticks and if not disallow flying
player.capabilities.allowFlying = true;
*/
}
}
代码示例来源:origin: SleepyTrousers/EnderIO
public static void doHoover(EntityPlayer player) {
Integer range = ItemConfig.magnetRange.get();
AxisAlignedBB aabb = new AxisAlignedBB(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range,
player.posZ + range);
List<Entity> interestingItems = selectEntitiesWithinAABB(player.world, aabb);
if (interestingItems != null) {
for (Entity entity : interestingItems) {
double x = player.posX - entity.posX;
double y = player.posY + player.eyeHeight * .75f - entity.posY;
double z = player.posZ - entity.posZ;
double distance = x * x + y * y + z * z;
if (distance < collisionDistanceSq) {
entity.onCollideWithPlayer(player);
} else {
double distancespeed = speed4 / distance;
entity.motionX += x * distancespeed;
if (y > 0) {
entity.motionY = 0.12;
} else {
entity.motionY += y * speed;
}
entity.motionZ += z * distancespeed;
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!