Search in sources :

Example 61 with Vector3d

use of org.joml.Vector3d in project chunkstories-api by Hugobros3.

the class PacketDecal method process.

@Override
public void process(PacketSender sender, DataInputStream in, PacketReceptionContext processor) throws IOException, PacketProcessingException {
    decalName = in.readUTF();
    Vector3d position = new Vector3d();
    position.x = (in.readDouble());
    position.y = (in.readDouble());
    position.z = (in.readDouble());
    Vector3d orientation = new Vector3d();
    orientation.x = (in.readDouble());
    orientation.y = (in.readDouble());
    orientation.z = (in.readDouble());
    Vector3d size = new Vector3d();
    size.x = (in.readDouble());
    size.y = (in.readDouble());
    size.z = (in.readDouble());
    if (processor instanceof ClientPacketsProcessor) {
        ClientPacketsProcessor cpp = (ClientPacketsProcessor) processor;
        cpp.getContext().getDecalsManager().drawDecal(position, orientation, size, decalName);
    }
}
Also used : ClientPacketsProcessor(io.xol.chunkstories.api.client.net.ClientPacketsProcessor) Vector3d(org.joml.Vector3d)

Example 62 with Vector3d

use of org.joml.Vector3d in project chunkstories-api by Hugobros3.

the class EntityComponentRotation method getDirectionLookingAt.

/**
 * @return A vector3d for the direction
 */
public Vector3dc getDirectionLookingAt() {
    Vector3d direction = new Vector3d();
    double a = ((-getHorizontalRotation()) / 360f * 2 * Math.PI);
    double b = ((getVerticalRotation()) / 360f * 2 * Math.PI);
    direction.x = (-Math.sin(a) * Math.cos(b));
    direction.y = (-Math.sin(b));
    direction.z = (-Math.cos(a) * Math.cos(b));
    return direction.normalize();
}
Also used : Vector3d(org.joml.Vector3d)

Example 63 with Vector3d

use of org.joml.Vector3d in project chunkstories-api by Hugobros3.

the class EntityBase method moveWithoutCollisionRestrain.

@Override
public void moveWithoutCollisionRestrain(double mx, double my, double mz) {
    Vector3d pos = new Vector3d(positionComponent.getLocation());
    pos.x = (pos.x() + mx);
    pos.y = (pos.y() + my);
    pos.z = (pos.z() + mz);
    positionComponent.setPosition(pos);
}
Also used : Vector3d(org.joml.Vector3d)

Example 64 with Vector3d

use of org.joml.Vector3d in project chunkstories-api by Hugobros3.

the class Math2 method mix.

public static Vector3d mix(Vector3d a, Vector3d b, double f) {
    Vector3d vec = new Vector3d();
    vec.x = (mixd(a.x, b.x, f));
    vec.y = (mixd(a.y, b.y, f));
    vec.z = (mixd(a.z, b.z, f));
    return vec;
}
Also used : Vector3d(org.joml.Vector3d)

Example 65 with Vector3d

use of org.joml.Vector3d in project chunkstories by Hugobros3.

the class ServerPlayer method updateTrackedEntities.

// Entity tracking
public void updateTrackedEntities() {
    EntityControllable controlledEntity = this.controlledEntity;
    if (controlledEntity == null)
        return;
    // Cache (idk if HotSpot makes it redudant but whatever)
    double world_size = controlledEntity.getWorld().getWorldSize();
    Location controlledEntityLocation = controlledEntity.getLocation();
    double ENTITY_VISIBILITY_SIZE = 192;
    Iterator<Entity> inRangeEntitiesIterator = controlledEntity.getWorld().getEntitiesInBox(controlledEntityLocation, new Vector3d(ENTITY_VISIBILITY_SIZE, ENTITY_VISIBILITY_SIZE, ENTITY_VISIBILITY_SIZE));
    while (inRangeEntitiesIterator.hasNext()) {
        Entity e = inRangeEntitiesIterator.next();
        // && chunk != null;
        boolean shouldTrack = e.shouldBeTrackedBy(this);
        boolean contains = subscribedEntities.contains(e);
        if (shouldTrack && !contains)
            this.subscribe(e);
        if (!shouldTrack && contains)
            this.unsubscribe(e);
    }
    Iterator<Entity> subscribedEntitiesIterator = subscribedEntities.iterator();
    while (subscribedEntitiesIterator.hasNext()) {
        Entity e = subscribedEntitiesIterator.next();
        Location loc = e.getLocation();
        // Distance calculations
        double dx = LoopingMathHelper.moduloDistance(controlledEntityLocation.x(), loc.x(), world_size);
        double dy = Math.abs(controlledEntityLocation.y() - loc.y());
        double dz = LoopingMathHelper.moduloDistance(controlledEntityLocation.z(), loc.z(), world_size);
        boolean inRange = (dx < ENTITY_VISIBILITY_SIZE && dz < ENTITY_VISIBILITY_SIZE && dy < ENTITY_VISIBILITY_SIZE);
        // Reasons other than distance to stop tracking this entity
        if (!e.shouldBeTrackedBy(this) || !inRange)
            this.unsubscribe(e);
    // No need to do anything as the component system handles the updates
    }
}
Also used : Entity(io.xol.chunkstories.api.entity.Entity) Vector3d(org.joml.Vector3d) EntityControllable(io.xol.chunkstories.api.entity.interfaces.EntityControllable) Location(io.xol.chunkstories.api.Location)

Aggregations

Vector3d (org.joml.Vector3d)117 Vector3dc (org.joml.Vector3dc)33 PhysicsObject (org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)20 BlockPos (net.minecraft.util.math.BlockPos)19 ShipTransform (org.valkyrienskies.mod.common.ships.ship_transform.ShipTransform)18 Location (io.xol.chunkstories.api.Location)12 Entity (io.xol.chunkstories.api.entity.Entity)11 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)9 World (net.minecraft.world.World)9 ShipData (org.valkyrienskies.mod.common.ships.ShipData)9 WorldClient (io.xol.chunkstories.api.world.WorldClient)8 WorldMaster (io.xol.chunkstories.api.world.WorldMaster)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 EntityShipMovementData (org.valkyrienskies.mod.common.entity.EntityShipMovementData)7 EntityControllable (io.xol.chunkstories.api.entity.interfaces.EntityControllable)6 IBlockState (net.minecraft.block.state.IBlockState)6 Vec3d (net.minecraft.util.math.Vec3d)6 Vector3f (org.joml.Vector3f)6 EntityLiving (io.xol.chunkstories.api.entity.EntityLiving)5 CellData (io.xol.chunkstories.api.world.cell.CellData)5