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();
}
}
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"));
}
}
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);
}
Aggregations