Search in sources :

Example 1 with EntityWithVelocity

use of io.xol.chunkstories.api.entity.interfaces.EntityWithVelocity in project chunkstories-api by Hugobros3.

the class PacketVelocityDelta method process.

@Override
public void process(PacketSender sender, DataInputStream in, PacketReceptionContext processor) throws IOException, PacketProcessingException {
    Vector3d delta = new Vector3d(in.readDouble(), in.readDouble(), in.readDouble());
    EntityControllable entity = ((ClientPacketsProcessor) processor).getContext().getPlayer().getControlledEntity();
    if (entity != null && entity instanceof EntityWithVelocity) {
        System.out.println("Debug: received velocity delta " + delta);
        ((EntityWithVelocity) entity).getVelocityComponent().addVelocity(delta);
    }
}
Also used : ClientPacketsProcessor(io.xol.chunkstories.api.client.net.ClientPacketsProcessor) EntityWithVelocity(io.xol.chunkstories.api.entity.interfaces.EntityWithVelocity) Vector3d(org.joml.Vector3d) EntityControllable(io.xol.chunkstories.api.entity.interfaces.EntityControllable)

Aggregations

ClientPacketsProcessor (io.xol.chunkstories.api.client.net.ClientPacketsProcessor)1 EntityControllable (io.xol.chunkstories.api.entity.interfaces.EntityControllable)1 EntityWithVelocity (io.xol.chunkstories.api.entity.interfaces.EntityWithVelocity)1 Vector3d (org.joml.Vector3d)1