Search in sources :

Example 1 with ITransformInterpolator

use of org.valkyrienskies.mod.common.ships.interpolation.ITransformInterpolator in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ShipTransformUpdateMessageHandler method onMessage.

@Override
@SuppressWarnings("Convert2Lambda")
public // errors. DON'T USE A LAMBDA
IMessage onMessage(final ShipTransformUpdateMessage message, final MessageContext ctx) {
    IThreadListener mainThread = Minecraft.getMinecraft();
    mainThread.addScheduledTask(new Runnable() {

        @Override
        public void run() {
            World world = Minecraft.getMinecraft().world;
            IPhysObjectWorld physObjectWorld = ValkyrienUtils.getPhysObjWorld(world);
            QueryableShipData worldData = QueryableShipData.get(world);
            for (Map.Entry<UUID, Tuple<ShipTransform, AxisAlignedBB>> transformUpdate : message.shipTransforms.entrySet()) {
                final UUID shipID = transformUpdate.getKey();
                final ShipTransform shipTransform = transformUpdate.getValue().getFirst();
                final AxisAlignedBB shipBB = transformUpdate.getValue().getSecond();
                final PhysicsObject physicsObject = ValkyrienUtils.getPhysObjWorld(world).getPhysObjectFromUUID(shipID);
                if (physicsObject != null) {
                    // Do not update the transform in ShipData, that will be done by PhysicsObject.tick()
                    ITransformInterpolator interpolator = physicsObject.getTransformInterpolator();
                    interpolator.onNewTransformPacket(shipTransform, shipBB);
                }
            }
        }
    });
    return null;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ShipTransform(org.valkyrienskies.mod.common.ships.ship_transform.ShipTransform) ITransformInterpolator(org.valkyrienskies.mod.common.ships.interpolation.ITransformInterpolator) IThreadListener(net.minecraft.util.IThreadListener) World(net.minecraft.world.World) IPhysObjectWorld(org.valkyrienskies.mod.common.ships.ship_world.IPhysObjectWorld) UUID(java.util.UUID) IPhysObjectWorld(org.valkyrienskies.mod.common.ships.ship_world.IPhysObjectWorld) QueryableShipData(org.valkyrienskies.mod.common.ships.QueryableShipData) PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)

Aggregations

UUID (java.util.UUID)1 IThreadListener (net.minecraft.util.IThreadListener)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 World (net.minecraft.world.World)1 QueryableShipData (org.valkyrienskies.mod.common.ships.QueryableShipData)1 ITransformInterpolator (org.valkyrienskies.mod.common.ships.interpolation.ITransformInterpolator)1 ShipTransform (org.valkyrienskies.mod.common.ships.ship_transform.ShipTransform)1 IPhysObjectWorld (org.valkyrienskies.mod.common.ships.ship_world.IPhysObjectWorld)1 PhysicsObject (org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)1