Search in sources :

Example 1 with WorldServerShipManager

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

the class MainCommand method teleportShipToPosition.

private static void teleportShipToPosition(final ShipData ship, final Vec3d position, final ICommandSender sender) {
    try {
        final World world = sender.getEntityWorld();
        final WorldServerShipManager shipManager = ValkyrienUtils.getServerShipManager(world);
        final PhysicsObject shipObject = shipManager.getPhysObjectFromUUID(ship.getUuid());
        // Create the new ship transform that moves the ship to this position
        final ShipTransform shipTransform = ship.getShipTransform();
        final ShipTransform newTransform = new ShipTransform(JOML.convert(position), shipTransform.getCenterCoord());
        if (shipObject != null) {
            // The ship already exists in the world, so we need to update the physics transform as well
            final PhysicsCalculations physicsCalculations = shipObject.getPhysicsCalculations();
            physicsCalculations.setForceToUseGameTransform(true);
            // Also update the transform in the ShipTransformationManager
            shipObject.setForceToUseShipDataTransform(true);
            shipObject.setTicksSinceShipTeleport(0);
        }
        // Update the ship transform of the ship data.
        ship.setPhysicsEnabled(false);
        ship.setPrevTickShipTransform(newTransform);
        ship.setShipTransform(newTransform);
        System.out.println(String.format("Teleporting ship %s to %s", ship.getName(), position.toString()));
    } catch (final Exception e) {
        e.printStackTrace();
    }
}
Also used : ShipTransform(org.valkyrienskies.mod.common.ships.ship_transform.ShipTransform) World(net.minecraft.world.World) PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject) PhysicsCalculations(org.valkyrienskies.mod.common.physics.PhysicsCalculations) WorldServerShipManager(org.valkyrienskies.mod.common.ships.ship_world.WorldServerShipManager)

Example 2 with WorldServerShipManager

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

the class MainCommand method deletePhyso.

private static void deletePhyso(ICommandSender sender, ShipData shipData, DeconstructState state) {
    final WorldServerShipManager world = ValkyrienUtils.getServerShipManager(sender.getEntityWorld());
    final PhysicsObject obj = world.getPhysObjectFromUUID(shipData.getUuid());
    if (obj != null) {
        obj.setDeconstructState(state);
        switch(state) {
            case DECONSTRUCT_NORMAL:
                sender.sendMessage(new TextComponentString("That ship is being deconstructed"));
                break;
            case DECONSTRUCT_IMMEDIATE_NO_COPY:
                sender.sendMessage(new TextComponentString("That ship will be deleted in the next tick."));
                break;
        }
    } else {
        sender.sendMessage(new TextComponentString("That ship is not loaded"));
    }
}
Also used : PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject) WorldServerShipManager(org.valkyrienskies.mod.common.ships.ship_world.WorldServerShipManager) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 3 with WorldServerShipManager

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

the class ValkyrienUtils method assembleShipAsOrderedByPlayer.

public void assembleShipAsOrderedByPlayer(World world, @Nullable EntityPlayerMP creator, BlockPos physicsInfuserPos, BlockFinder.BlockFinderType blockFinderType) {
    if (world.isRemote) {
        throw new IllegalStateException("This method cannot be invoked on client side!");
    }
    if (!(world instanceof WorldServer)) {
        throw new IllegalStateException("The world " + world + " wasn't an instance of WorldServer");
    }
    // Create the ship data that we will use to make the ship with later.
    ShipData shipData = createNewShip(world, physicsInfuserPos);
    // Queue the ship spawn operation
    ((WorldServerShipManager) ValkyrienUtils.getPhysObjWorld(world)).queueShipSpawn(shipData, physicsInfuserPos, blockFinderType);
}
Also used : QueryableShipData(org.valkyrienskies.mod.common.ships.QueryableShipData) ShipData(org.valkyrienskies.mod.common.ships.ShipData) WorldServer(net.minecraft.world.WorldServer) WorldServerShipManager(org.valkyrienskies.mod.common.ships.ship_world.WorldServerShipManager)

Aggregations

WorldServerShipManager (org.valkyrienskies.mod.common.ships.ship_world.WorldServerShipManager)3 PhysicsObject (org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)2 TextComponentString (net.minecraft.util.text.TextComponentString)1 World (net.minecraft.world.World)1 WorldServer (net.minecraft.world.WorldServer)1 PhysicsCalculations (org.valkyrienskies.mod.common.physics.PhysicsCalculations)1 QueryableShipData (org.valkyrienskies.mod.common.ships.QueryableShipData)1 ShipData (org.valkyrienskies.mod.common.ships.ShipData)1 ShipTransform (org.valkyrienskies.mod.common.ships.ship_transform.ShipTransform)1