public Vector3f add(Vector3f v) { return add(v.x, v.y, v.z); }
public Vector3f add(double x, double y, double z) { return add((float) x, (float) y, (float) z); }
public Vector3f add(double x, double y, double z) { return add((float) x, (float) y, (float) z); }
public Vector3f add(Vector3f v) { return add(v.x, v.y, v.z); }
@Nonnull @Override public Vector3f getGamePosition() { return getPosition().add(0, data.getHeight(), 0); }
/** * Calculates the linear interpolation between a and b with the given percent * * @param a The first know value * @param b The second know value * @param percent The percent * @return the interpolated vector */ public static Vector3f lerp(Vector3f a, Vector3f b, float percent) { return a.mul(1 - percent).add(b.mul(percent)); }
/** * Calculates the linear interpolation between a and b with the given percent * * @param a The first know value * @param b The second know value * @param percent The percent * @return the interpolated vector */ public static Vector3f lerp(Vector3f a, Vector3f b, float percent) { return a.mul(1 - percent).add(b.mul(percent)); }
public BoundingBox grow(float x, float y, float z) { return new BoundingBox(start.sub(x, y, z), end.add(x, y, z)); } }
@Override public void execute(CommandExecutorSource source, String[] args) throws Exception { if (source instanceof Player) { Player player = (Player) source; Level level = player.getLevel(); double xDiff = 0; level.spawn(Zombie.class, level.getSpawnLocation().add(xDiff += 1.5, 0, 0)); } } }
default BoundingBox getBoundingBox(Block block) { Vector3f asFloat = block.getLevelLocation().toFloat(); return new BoundingBox(asFloat, asFloat.add(1, 1, 1)); }
private Triangle[] subdivide() { final Vector3f e0 = v1.sub(v0).div(2); final Vector3f va = v0.add(e0); final Vector3f e1 = v2.sub(v1).div(2); final Vector3f vb = v1.add(e1); final Vector3f e2 = v0.sub(v2).div(2); final Vector3f vc = v2.add(e2); return new Triangle[]{ new Triangle(v0, va, vc), new Triangle(va, v1, vb), new Triangle(vc, vb, v2), new Triangle(va, vb, vc) }; } }
@Override public void handle(McpeDropItem packet) { Health health = ensureAndGet(Health.class); if (!spawned || health.isDead()) { return; } if (packet.getItem().getItemType() == BlockTypes.AIR) { return; } // TODO: Events Optional<ItemStack> stackOptional = playerInventory.getStackInHand(); if (!stackOptional.isPresent()) { sendPlayerInventory(); return; } DroppedItem item = new VoxelwindDroppedItem(getLevel(), getPosition().add(0, 1.3, 0), getServer(), stackOptional.get()); item.setMotion(getDirectionVector().mul(0.4)); playerInventory.clearItem(playerInventory.getHeldInventorySlot()); }
final Vector3f nextB = rim.get(nextI); final Vector3f nextBN = new Vector3f(nextB.getX() / radiusSquared, halfHeight - nextB.getY(), nextB.getZ() / radiusSquared).normalize(); final Vector3f tn = bn.add(nextBN).normalize();
Collection<ItemStack> drops = blockBehavior.getDrops(getServer(), PlayerSession.this, block, playerInventory.getStackInHand().orElse(null)); for (ItemStack drop : drops) { DroppedItem item = getLevel().dropItem(drop, block.getLevelLocation().toFloat().add(0.5, 0.5, 0.5)); item.ensureAndGet(PickupDelay.class).setDelayPickupTicks(5);
radius * sinPhi * TrigMath.cos(radTheta)); addVector(positions, p.add(0, halfHeight, 0)); addVector(normals, p.normalize());
@Override public void run(Entity entity) { Physics physics = entity.ensureAndGet(Physics.class); if (entity.getMotion().lengthSquared() > 0) { boolean onGroundPreviously = entity.isOnGround(); entity.setPositionFromSystem(entity.getPosition().add(entity.getMotion())); boolean onGroundNow = entity.isOnGround(); if (!onGroundPreviously && onGroundNow) { entity.setPositionFromSystem(new Vector3f(entity.getPosition().getX(), entity.getPosition().getFloorY(), entity.getPosition().getZ())); entity.setMotion(Vector3f.ZERO); } else { entity.setMotion(entity.getMotion().mul(1f - physics.getDrag())); if (!onGroundNow) { entity.setMotion(entity.getMotion().sub(0, physics.getGravity(), 0)); } } } } }