Java Code Examples for net.minecraft.entity.player.EntityPlayerMP#getEyeHeight()
The following examples show how to use
net.minecraft.entity.player.EntityPlayerMP#getEyeHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerUtils.java From GriefPrevention with MIT License | 4 votes |
public static RayTraceResult rayTracePlayerEyes(EntityPlayerMP player) { double distance = SpongeImplHooks.getBlockReachDistance(player) + 1; Vec3d startPos = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ); Vec3d endPos = startPos.add(new Vec3d(player.getLookVec().x * distance, player.getLookVec().y * distance, player.getLookVec().z * distance)); return player.world.rayTraceBlocks(startPos, endPos); }
Example 2
Source File: ServerHandler.java From NotEnoughItems with MIT License | 4 votes |
private void updateMagneticPlayer(EntityPlayerMP player, PlayerSave save) { if (!save.isActionEnabled("magnet") || player.isDead) return; float distancexz = 16; float distancey = 8; double maxspeedxz = 0.5; double maxspeedy = 0.5; double speedxz = 0.05; double speedy = 0.07; List<EntityItem> items = player.worldObj.getEntitiesWithinAABB(EntityItem.class, player.getEntityBoundingBox().expand(distancexz, distancey, distancexz)); for (EntityItem item : items) { if (item.cannotPickup()) continue; if (!NEIServerUtils.canItemFitInInventory(player, item.getEntityItem())) continue; if (save.magneticItems.add(item)) NEISPH.sendAddMagneticItemTo(player, item); double dx = player.posX - item.posX; double dy = player.posY + player.getEyeHeight() - item.posY; double dz = player.posZ - item.posZ; double absxz = Math.sqrt(dx * dx + dz * dz); double absy = Math.abs(dy); if (absxz > distancexz) continue; if (absxz < 1) item.onCollideWithPlayer(player); if (absxz > 1) { dx /= absxz; dz /= absxz; } if (absy > 1) dy /= absy; double vx = item.motionX + speedxz * dx; double vy = item.motionY + speedy * dy; double vz = item.motionZ + speedxz * dz; double absvxz = Math.sqrt(vx * vx + vz * vz); double absvy = Math.abs(vy); double rationspeedxz = absvxz / maxspeedxz; if (rationspeedxz > 1) { vx /= rationspeedxz; vz /= rationspeedxz; } double rationspeedy = absvy / maxspeedy; if (absvy > 1) vy /= rationspeedy; item.motionX = vx; item.motionY = vy; item.motionZ = vz; } }