Search in sources :

Example 1 with ShipPositionData

use of ValkyrienWarfareBase.Interaction.ShipUUIDToPosData.ShipPositionData in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class AirshipMapCommand method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    String term = args[0];
    if (term.equals("tpto")) {
        String shipName = args[1];
        if (args.length > 2) {
            for (int i = 2; i < args.length; i++) {
                shipName += " " + args[i];
            }
        }
        Entity player = sender.getCommandSenderEntity();
        World world = player.worldObj;
        ShipNameUUIDData data = ShipNameUUIDData.get(world);
        if (data.ShipNameToLongMap.containsKey(shipName)) {
            long shipUUIDMostSig = data.ShipNameToLongMap.get(shipName);
            ShipUUIDToPosData posData = ShipUUIDToPosData.get(world);
            ShipPositionData positionData = posData.getShipPositionData(shipUUIDMostSig);
            double posX = positionData.shipPosition.X;
            double posY = positionData.shipPosition.Y;
            double posZ = positionData.shipPosition.Z;
            if (player instanceof EntityPlayerMP) {
                EntityPlayerMP playerMP = (EntityPlayerMP) player;
                ((EntityPlayerMP) player).connection.setPlayerLocation(posX, posY, posZ, 0, 0);
            }
        }
    }
    if (term.equals("help")) {
        sender.addChatMessage(new TextComponentString("tpto"));
    }
}
Also used : Entity(net.minecraft.entity.Entity) ShipUUIDToPosData(ValkyrienWarfareBase.Interaction.ShipUUIDToPosData) ShipNameUUIDData(ValkyrienWarfareBase.Interaction.ShipNameUUIDData) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TextComponentString(net.minecraft.util.text.TextComponentString) ShipPositionData(ValkyrienWarfareBase.Interaction.ShipUUIDToPosData.ShipPositionData) World(net.minecraft.world.World) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 2 with ShipPositionData

use of ValkyrienWarfareBase.Interaction.ShipUUIDToPosData.ShipPositionData in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunner method getBedSpawnLocation.

public static BlockPos getBedSpawnLocation(BlockPos toReturn, World worldIn, BlockPos bedLocation, boolean forceSpawn) {
    //    	System.out.println("Keep their heads ringing");
    int chunkX = bedLocation.getX() >> 4;
    int chunkZ = bedLocation.getZ() >> 4;
    long chunkPos = ChunkPos.chunkXZ2Int(chunkX, chunkZ);
    UUID shipManagingID = ValkyrienWarfareMod.chunkManager.getShipIDManagingPos_Persistant(worldIn, chunkX, chunkZ);
    if (shipManagingID != null) {
        ShipPositionData positionData = ValkyrienWarfareMod.chunkManager.getShipPosition_Persistant(worldIn, shipManagingID);
        if (positionData != null) {
            double[] lToWTransform = RotationMatrices.convertToDouble(positionData.lToWTransform);
            Vector bedPositionInWorld = new Vector(bedLocation.getX() + .5D, bedLocation.getY() + .5D, bedLocation.getZ() + .5D);
            RotationMatrices.applyTransform(lToWTransform, bedPositionInWorld);
            bedPositionInWorld.Y += 1D;
            bedLocation = new BlockPos(bedPositionInWorld.X, bedPositionInWorld.Y, bedPositionInWorld.Z);
            return bedLocation;
        } else {
            System.err.println("A ship just had Chunks claimed persistant, but not any position data persistant");
        }
    }
    return toReturn;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) ShipPositionData(ValkyrienWarfareBase.Interaction.ShipUUIDToPosData.ShipPositionData) UUID(java.util.UUID) Vector(ValkyrienWarfareBase.API.Vector)

Aggregations

ShipPositionData (ValkyrienWarfareBase.Interaction.ShipUUIDToPosData.ShipPositionData)2 Vector (ValkyrienWarfareBase.API.Vector)1 ShipNameUUIDData (ValkyrienWarfareBase.Interaction.ShipNameUUIDData)1 ShipUUIDToPosData (ValkyrienWarfareBase.Interaction.ShipUUIDToPosData)1 UUID (java.util.UUID)1 Entity (net.minecraft.entity.Entity)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 BlockPos (net.minecraft.util.math.BlockPos)1 TextComponentString (net.minecraft.util.text.TextComponentString)1 World (net.minecraft.world.World)1