Search in sources :

Example 1 with TileEntityBoatChair

use of org.valkyrienskies.mod.common.tileentity.TileEntityBoatChair in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class BlockBoatChair method getTorqueInGlobal.

@Nullable
@Override
public Vector3dc getTorqueInGlobal(PhysicsCalculations physicsCalculations, BlockPos pos) {
    final World world = physicsCalculations.getParent().getWorld();
    final TileEntity tileEntity = world.getTileEntity(pos);
    if (tileEntity instanceof TileEntityBoatChair) {
        return ((TileEntityBoatChair) tileEntity).getTorqueInGlobal(physicsCalculations);
    }
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityBoatChair(org.valkyrienskies.mod.common.tileentity.TileEntityBoatChair) World(net.minecraft.world.World) Nullable(javax.annotation.Nullable)

Example 2 with TileEntityBoatChair

use of org.valkyrienskies.mod.common.tileentity.TileEntityBoatChair in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class BlockBoatChair method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote) {
        Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(worldIn, pos);
        if (physicsObject.isPresent()) {
            TileEntity tileEntity = worldIn.getTileEntity(pos);
            if (tileEntity instanceof TileEntityBoatChair) {
                Vector3d playerPos = new Vector3d(playerIn.posX, playerIn.posY, playerIn.posZ);
                physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(playerPos, TransformType.SUBSPACE_TO_GLOBAL);
                playerIn.posX = playerPos.x;
                playerIn.posY = playerPos.y;
                playerIn.posZ = playerPos.z;
                // Only mount the player if they're standing on the ship.
                final EntityShipMovementData entityShipMovementData = ValkyrienUtils.getEntityShipMovementDataFor(playerIn);
                if (entityShipMovementData.getTicksSinceTouchedShip() == 0 && (entityShipMovementData.getLastTouchedShip() == physicsObject.get().getShipData())) {
                    Vector3dc localMountPos = getPlayerMountOffset(state, pos);
                    ValkyrienUtils.fixEntityToShip(playerIn, localMountPos, physicsObject.get());
                }
                ((TileEntityBoatChair) tileEntity).setPilotEntity(playerIn);
                physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(playerPos, TransformType.GLOBAL_TO_SUBSPACE);
                playerIn.posX = playerPos.x;
                playerIn.posY = playerPos.y;
                playerIn.posZ = playerPos.z;
            }
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EntityShipMovementData(org.valkyrienskies.mod.common.entity.EntityShipMovementData) Vector3dc(org.joml.Vector3dc) Vector3d(org.joml.Vector3d) TileEntityBoatChair(org.valkyrienskies.mod.common.tileentity.TileEntityBoatChair) PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)2 TileEntityBoatChair (org.valkyrienskies.mod.common.tileentity.TileEntityBoatChair)2 Nullable (javax.annotation.Nullable)1 World (net.minecraft.world.World)1 Vector3d (org.joml.Vector3d)1 Vector3dc (org.joml.Vector3dc)1 EntityShipMovementData (org.valkyrienskies.mod.common.entity.EntityShipMovementData)1 PhysicsObject (org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)1